Browse Source

Merge commit '2ec0fb9' into bfgminer

Luke Dashjr 13 years ago
parent
commit
c3526786ab
3 changed files with 22 additions and 17 deletions
  1. 12 2
      API-README
  2. 10 2
      api.c
  3. 0 13
      driver-icarus.c

+ 12 - 2
API-README

@@ -310,13 +310,23 @@ miner.php - an example web page to access the API
 Feature Changelog for external applications using the API:
 
 
-API V1.13
+API V1.14
+
+Modified API commands:
+ 'stats' - more icarus timing stats added
+
+The internal code for handling data was rewritten (~25% of the code)
+Completely backward compatible
+
+----------
+
+API V1.13 (cgminer v2.4.4)
 
 Added API commands:
  'check'
 
 Support was added to cgminer for API access groups with the --api-groups option
-It's 100% backwards compatible with previous --api-access commands
+It's 100% backward compatible with previous --api-access commands
 
 ----------
 

+ 10 - 2
api.c

@@ -166,7 +166,7 @@ static const char SEPARATOR = '|';
 #define SEPSTR "|"
 static const char GPUSEP = ',';
 
-static const char *APIVERSION = "1.13";
+static const char *APIVERSION = "1.14";
 static const char *DEAD = "Dead";
 static const char *SICK = "Sick";
 static const char *NOSTART = "NoStart";
@@ -179,6 +179,7 @@ static const char *DYNAMIC = _DYNAMIC;
 
 static const char *YES = "Y";
 static const char *NO = "N";
+static const char *NULLSTR = "(null)";
 
 static const char *DEVICECODE = ""
 #ifdef HAVE_OPENCL
@@ -683,6 +684,13 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
 
 	api_data->data_was_malloc = copy_data;
 
+	// Avoid crashing on bad data
+	if (data == NULL) {
+		api_data->type = type = API_CONST;
+		data = (void *)NULLSTR;
+		api_data->data_was_malloc = copy_data = false;
+	}
+
 	if (!copy_data)
 	{
 		api_data->data = data;
@@ -1691,7 +1699,7 @@ static void summary(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, boo
 #ifdef WANT_CPUMINE
 	char *algo = (char *)(algo_names[opt_algo]);
 	if (algo == NULL)
-		algo = "(null)";
+		algo = (char *)NULLSTR;
 #endif
 
 	utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;

+ 0 - 13
driver-icarus.c

@@ -777,7 +777,6 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	return hash_count;
 }
 
-//static void icarus_api_stats(char *buf, struct cgpu_info *cgpu, bool isjson)
 static struct api_data *icarus_api_stats(struct cgpu_info *cgpu)
 {
 	struct api_data *root = NULL;
@@ -800,18 +799,6 @@ static struct api_data *icarus_api_stats(struct cgpu_info *cgpu)
 	root = api_add_uint(root, "timing_values", &(info->history[0].values), false);
 	root = api_add_const(root, "timing_mode", timing_mode_str(info->timing_mode), false);
 	root = api_add_bool(root, "is_timing", &(info->do_icarus_timing), false);
-/*
-	sprintf(buf, isjson
-		? "\"read_count\":%d,\"fullnonce\":%f,\"count\":%d,\"Hs\":%.15f,\"W\":%f,\"total_values\":%u,\"range\":%"PRIu64",\"history_count\":%"PRIu64",\"history_time\":%f,\"min_data_count\":%u,\"timing_values\":%u"
-		: "read_count=%d,fullnonce=%f,count=%d,Hs=%.15f,W=%f,total_values=%u,range=%"PRIu64",history_count=%"PRIu64",history_time=%f,min_data_count=%u,timing_values=%u",
-		info->read_count, info->fullnonce,
-		info->count, info->Hs, info->W,
-		info->values, info->hash_count_range,
-		info->history_count,
-		(double)(info->history_time.tv_sec)
-			+ ((double)(info->history_time.tv_usec))/((double)1000000),
-		info->min_data_count, info->history[0].values);
-*/
 
 	return root;
 }