Browse Source

api.c replace BUFSIZ (linux/windows have different values)

nfactor-troky
Kano 13 years ago
parent
commit
a0936815a3
  1. 33
      api.c

33
api.c

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

Loading…
Cancel
Save