Browse Source

Merge pull request #207 from kanoi/apibuf

api.c replace BUFSIZ (linux/windows have different values)
nfactor-troky
Con Kolivas 12 years ago
parent
commit
2635765438
  1. 33
      api.c

33
api.c

@ -142,6 +142,9 @@
// Current code assumes it can socket send this size also // Current code assumes it can socket send this size also
#define MYBUFSIZ 65432 // TODO: intercept before it's exceeded #define MYBUFSIZ 65432 // TODO: intercept before it's exceeded
// BUFSIZ varies on Windows and Linux
#define TMPBUFSIZ 8192
// Number of requests to queue - normally would be small // Number of requests to queue - normally would be small
// However lots of PGA's may mean more // However lots of PGA's may mean more
#define QUEUE 100 #define QUEUE 100
@ -763,7 +766,7 @@ static void apiversion(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson) static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
int pgacount = 0; int pgacount = 0;
int cpucount = 0; int cpucount = 0;
char *adlinuse = (char *)NO; char *adlinuse = (char *)NO;
@ -804,7 +807,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
static void gpustatus(int gpu, bool isjson) static void gpustatus(int gpu, bool isjson)
{ {
char intensity[20]; char intensity[20];
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
char *enabled; char *enabled;
char *status; char *status;
float gt, gv; float gt, gv;
@ -856,7 +859,7 @@ static void gpustatus(int gpu, bool isjson)
#if defined(USE_BITFORCE) || defined(USE_ICARUS) || defined(USE_ZTEX) #if defined(USE_BITFORCE) || defined(USE_ICARUS) || defined(USE_ZTEX)
static void pgastatus(int pga, bool isjson) static void pgastatus(int pga, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
char *enabled; char *enabled;
char *status; char *status;
int numpga = numpgas(); int numpga = numpgas();
@ -908,7 +911,7 @@ static void pgastatus(int pga, bool isjson)
#ifdef WANT_CPUMINE #ifdef WANT_CPUMINE
static void cpustatus(int cpu, bool isjson) static void cpustatus(int cpu, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
if (opt_n_threads > 0 && cpu >= 0 && cpu < num_processors) { if (opt_n_threads > 0 && cpu >= 0 && cpu < num_processors) {
struct cgpu_info *cgpu = &cpus[cpu]; struct cgpu_info *cgpu = &cpus[cpu];
@ -1188,7 +1191,7 @@ static void cpudev(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
static void poolstatus(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson) static void poolstatus(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
char *status, *lp; char *status, *lp;
char *rpc_url; char *rpc_url;
char *rpc_user; char *rpc_user;
@ -1400,7 +1403,7 @@ static void gpurestart(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
static void gpucount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson) static void gpucount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
strcpy(io_buffer, message(MSG_NUMGPU, 0, NULL, isjson)); strcpy(io_buffer, message(MSG_NUMGPU, 0, NULL, isjson));
@ -1414,7 +1417,7 @@ static void gpucount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bo
static void pgacount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson) static void pgacount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
int count = 0; int count = 0;
#if defined(USE_BITFORCE) || defined(USE_ICARUS) || defined(USE_ZTEX) #if defined(USE_BITFORCE) || defined(USE_ICARUS) || defined(USE_ZTEX)
@ -1433,7 +1436,7 @@ static void pgacount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bo
static void cpucount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson) static void cpucount(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
int count = 0; int count = 0;
#ifdef WANT_CPUMINE #ifdef WANT_CPUMINE
@ -1863,7 +1866,7 @@ void privileged(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool is
void notifystatus(int device, struct cgpu_info *cgpu, bool isjson) void notifystatus(int device, struct cgpu_info *cgpu, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
char *reason; char *reason;
if (cgpu->device_last_not_well == 0) if (cgpu->device_last_not_well == 0)
@ -1940,7 +1943,7 @@ static void notify(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool
static void devdetails(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson) static void devdetails(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
struct cgpu_info *cgpu; struct cgpu_info *cgpu;
int i; int i;
@ -2006,7 +2009,7 @@ void dosave(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
static int itemstats(int i, char *id, struct cgminer_stats *stats, char *extra, bool isjson) static int itemstats(int i, char *id, struct cgminer_stats *stats, char *extra, bool isjson)
{ {
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
if (stats->getwork_calls || (extra != NULL && *extra)) if (stats->getwork_calls || (extra != NULL && *extra))
{ {
@ -2032,7 +2035,7 @@ static int itemstats(int i, char *id, struct cgminer_stats *stats, char *extra,
} }
static void minerstats(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson) static void minerstats(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson)
{ {
char extra[BUFSIZ]; char extra[TMPBUFSIZ];
char id[20]; char id[20];
int i, j; int i, j;
@ -2300,8 +2303,8 @@ static void *restart_thread(__maybe_unused void *userdata)
void api(int api_thr_id) void api(int api_thr_id)
{ {
struct thr_info bye_thr; struct thr_info bye_thr;
char buf[BUFSIZ]; char buf[TMPBUFSIZ];
char param_buf[BUFSIZ]; char param_buf[TMPBUFSIZ];
const char *localaddr = "127.0.0.1"; const char *localaddr = "127.0.0.1";
SOCKETTYPE c; SOCKETTYPE c;
int n, bound; int n, bound;
@ -2434,7 +2437,7 @@ void api(int api_thr_id)
applog(LOG_DEBUG, "API: connection from %s - %s", connectaddr, addrok ? "Accepted" : "Ignored"); applog(LOG_DEBUG, "API: connection from %s - %s", connectaddr, addrok ? "Accepted" : "Ignored");
if (addrok) { if (addrok) {
n = recv(c, &buf[0], BUFSIZ-1, 0); n = recv(c, &buf[0], TMPBUFSIZ-1, 0);
if (SOCKETFAIL(n)) if (SOCKETFAIL(n))
buf[0] = '\0'; buf[0] = '\0';
else else

Loading…
Cancel
Save