Browse Source

Track which pools have active longpoll connections

Luke Dashjr 11 years ago
parent
commit
ddb55fe0c8
3 changed files with 13 additions and 0 deletions
  1. 2 0
      miner.c
  2. 1 0
      miner.h
  3. 10 0
      util.c

+ 2 - 0
miner.c

@@ -9813,6 +9813,7 @@ static void wait_lpcurrent(struct pool *pool)
 {
 	while (!cnx_needed(pool))
 	{
+		pool->lp_active = false;
 		mutex_lock(&lp_lock);
 		pthread_cond_wait(&lp_cond, &lp_lock);
 		mutex_unlock(&lp_lock);
@@ -9954,6 +9955,7 @@ lpfail:
 	}
 
 out:
+	pool->lp_active = false;
 	curl_easy_cleanup(curl);
 
 	return NULL;

+ 1 - 0
miner.h

@@ -1223,6 +1223,7 @@ struct pool {
 	char *lp_id;
 	enum pool_protocol lp_proto;
 	curl_socket_t lp_socket;
+	bool lp_active;
 
 	unsigned int getwork_requested;
 	unsigned int stale_shares;

+ 10 - 0
util.c

@@ -112,6 +112,7 @@ struct json_rpc_call_state {
 	struct curl_slist *headers;
 	struct upload_buffer upload_data;
 	struct pool *pool;
+	bool longpoll;
 };
 
 // aka data_buffer_write
@@ -164,6 +165,12 @@ static size_t upload_data_cb(void *ptr, size_t size, size_t nmemb,
 	struct json_rpc_call_state * const state = user_data;
 	struct upload_buffer * const ub = &state->upload_data;
 	unsigned int len = size * nmemb;
+	
+	if (state->longpoll)
+	{
+		struct pool * const pool = state->pool;
+		pool->lp_active = true;
+	}
 
 	if (len > ub->len)
 		len = ub->len;
@@ -404,7 +411,10 @@ void json_rpc_call_async(CURL *curl, const char *url,
 	struct curl_slist *headers = NULL;
 
 	if (longpoll)
+	{
 		state->all_data.idlemarker = &pool->lp_socket;
+		state->longpoll = true;
+	}
 
 	/* it is assumed that 'curl' is freshly [re]initialized at this pt */