Browse Source

SSM: Clean up stratumsrv_job when pruning it

Luke Dashjr 12 years ago
parent
commit
aa1ea6546e
3 changed files with 18 additions and 2 deletions
  1. 10 2
      driver-stratum.c
  2. 7 0
      miner.c
  3. 1 0
      miner.h

+ 10 - 2
driver-stratum.c

@@ -150,6 +150,15 @@ void stratumsrv_update_notify_str(struct pool * const pool, bool clean)
 	}
 }
 
+static
+void _ssj_free(struct stratumsrv_job * const ssj)
+{
+	free(ssj->my_job_id);
+	stratum_work_clean(&ssj->swork);
+	free(ssj->nonce1);
+	free(ssj);
+}
+
 static
 void _stratumsrv_update_notify(evutil_socket_t fd, short what, __maybe_unused void *p)
 {
@@ -179,8 +188,7 @@ void _stratumsrv_update_notify(evutil_socket_t fd, short what, __maybe_unused vo
 		HASH_ITER(hh, _ssm_jobs, ssj, tmp)
 		{
 			HASH_DEL(_ssm_jobs, ssj);
-			//FIXME: stratum_work_clean(ssj);
-			free(ssj);
+			_ssj_free(ssj);
 		}
 	}
 	

+ 7 - 0
miner.c

@@ -7926,6 +7926,13 @@ void stratum_work_cpy(struct stratum_work * const dst, const struct stratum_work
 	bytes_cpy(&dst->merkle_bin, &src->merkle_bin);
 }
 
+void stratum_work_clean(struct stratum_work * const swork)
+{
+	free(swork->job_id);
+	bytes_free(&swork->coinbase);
+	bytes_free(&swork->merkle_bin);
+}
+
 /* Generates stratum based work based on the most recent notify information
  * from the pool. This will keep generating work while a pool is down so we use
  * other means to detect when the pool has died in stratum_thread */

+ 1 - 0
miner.h

@@ -1332,6 +1332,7 @@ struct work {
 extern void get_datestamp(char *, size_t, time_t);
 #define get_now_datestamp(buf, bufsz)  get_datestamp(buf, bufsz, INVALID_TIMESTAMP)
 extern void stratum_work_cpy(struct stratum_work *dst, const struct stratum_work *src);
+extern void stratum_work_clean(struct stratum_work *);
 extern void gen_stratum_work2(struct work *, struct stratum_work *, const char *nonce1);
 extern void inc_hw_errors2(struct thr_info *thr, const struct work *work, const uint32_t *bad_nonce_p);
 extern void inc_hw_errors(struct thr_info *, const struct work *, const uint32_t bad_nonce);