Browse Source

Provide basic framework for restarting stratum depending on whether resume support exists or not.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
4cde791e9f
  1. 8
      cgminer.c
  2. 28
      util.c
  3. 1
      util.h

8
cgminer.c

@ -4720,9 +4720,9 @@ static void *stratum_thread(void *userdata) @@ -4720,9 +4720,9 @@ static void *stratum_thread(void *userdata)
clear_pool_work(pool);
wait_lpcurrent(pool);
if (!initiate_stratum(pool) || !auth_stratum(pool)) {
if (!restart_stratum(pool)) {
pool_died(pool);
while (!initiate_stratum(pool) || !auth_stratum(pool)) {
while (!restart_stratum(pool)) {
if (pool->removed)
goto out;
sleep(30);
@ -4757,11 +4757,11 @@ static void *stratum_thread(void *userdata) @@ -4757,11 +4757,11 @@ static void *stratum_thread(void *userdata)
if (pool == current_pool())
restart_threads();
if (initiate_stratum(pool) && auth_stratum(pool))
if (restart_stratum(pool))
continue;
pool_died(pool);
while (!initiate_stratum(pool) || !auth_stratum(pool)) {
while (!restart_stratum(pool)) {
if (pool->removed)
goto out;
sleep(30);

28
util.c

@ -1513,6 +1513,34 @@ out: @@ -1513,6 +1513,34 @@ out:
return ret;
}
/* Placeholder for real resume function in the future */
static bool resume_stratum(struct pool *pool)
{
mutex_lock(&pool->pool_lock);
free(pool->sessionid);
pool->sessionid = NULL;
mutex_unlock(&pool->pool_lock);
return false;
}
bool restart_stratum(struct pool *pool)
{
bool resume;
mutex_lock(&pool->pool_lock);
resume = pool->sessionid != NULL;
mutex_unlock(&pool->pool_lock);
if (resume && !resume_stratum(pool))
return false;
else if (!initiate_stratum(pool))
return false;
if (!auth_stratum(pool))
return false;
return true;
}
void suspend_stratum(struct pool *pool)
{
applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);

1
util.h

@ -52,6 +52,7 @@ bool parse_method(struct pool *pool, char *s); @@ -52,6 +52,7 @@ bool parse_method(struct pool *pool, char *s);
bool extract_sockaddr(struct pool *pool, char *url);
bool auth_stratum(struct pool *pool);
bool initiate_stratum(struct pool *pool);
bool restart_stratum(struct pool *pool);
void suspend_stratum(struct pool *pool);
void dev_error(struct cgpu_info *dev, enum dev_reason reason);
void *realloc_strcat(char *ptr, char *s);

Loading…
Cancel
Save