Merge pull request #207 from kanoi/apibuf api.c replace BUFSIZ (linux/windows have different values)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
diff --git a/api.c b/api.c
index a0c2e56..731c4e1 100644
--- a/api.c
+++ b/api.c
@@ -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,
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,
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)
#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)
#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)
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)
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
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
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
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
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)
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,
}
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)
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)
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