Retry bug fix
(hopefully)
This commit is contained in:
parent
073340f0b8
commit
7d95c8f995
22
src/api.c
22
src/api.c
@ -473,12 +473,10 @@ static enum error api_ratelimit()
|
|||||||
|
|
||||||
MS_TO_TIMESPEC_L(ts, mswait);
|
MS_TO_TIMESPEC_L(ts, mswait);
|
||||||
if (nanosleep(&ts, NULL) == -1) {
|
if (nanosleep(&ts, NULL) == -1) {
|
||||||
if (errno == EINTR) {
|
if (errno == EINTR && should_exit)
|
||||||
uio_error("Nanosleep got interrupted");
|
|
||||||
return ERR_SHOULD_EXIT;
|
return ERR_SHOULD_EXIT;
|
||||||
} else {
|
else
|
||||||
uio_error("Nanosleep failed");
|
uio_error("Nanosleep failed: %s", strerror(errno));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NOERR;
|
return NOERR;
|
||||||
@ -694,7 +692,13 @@ static enum error api_cmd_base_pref(char buffer[API_BUFSIZE], int send_len,
|
|||||||
while (retry_count < API_MAX_TRYAGAIN &&
|
while (retry_count < API_MAX_TRYAGAIN &&
|
||||||
api_g_retry_count < API_MAX_TRYAGAIN) {
|
api_g_retry_count < API_MAX_TRYAGAIN) {
|
||||||
long code;
|
long code;
|
||||||
ssize_t res_len = api_send(buffer, send_len, API_BUFSIZE);
|
char l_buff[API_BUFSIZE];
|
||||||
|
ssize_t res_len;
|
||||||
|
|
||||||
|
/* Need the copy because the response will be written here too,
|
||||||
|
* and we will send the response back when retrying */
|
||||||
|
memcpy(l_buff, buffer, send_len);
|
||||||
|
res_len = api_send(buffer, send_len, API_BUFSIZE);
|
||||||
|
|
||||||
if (res_len < 0) {
|
if (res_len < 0) {
|
||||||
if (res_len == -2 && should_exit)
|
if (res_len == -2 && should_exit)
|
||||||
@ -726,6 +730,8 @@ static enum error api_cmd_base_pref(char buffer[API_BUFSIZE], int send_len,
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Copy the saved command back */
|
||||||
|
memcpy(buffer, l_buff, send_len);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,9 +741,11 @@ static enum error api_cmd_base_pref(char buffer[API_BUFSIZE], int send_len,
|
|||||||
uio_debug("Let's try loggin in agane");
|
uio_debug("Let's try loggin in agane");
|
||||||
api_authed = false; /* We got logged out probably */
|
api_authed = false; /* We got logged out probably */
|
||||||
err = api_auth(); /* -> will call this function */
|
err = api_auth(); /* -> will call this function */
|
||||||
if (api_g_retry_count < API_MAX_TRYAGAIN)
|
if (api_g_retry_count < API_MAX_TRYAGAIN) {
|
||||||
|
memcpy(buffer, l_buff, send_len);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user