mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 14:58:01 +00:00
Use raw recv() command in place of curl_easy_recv since the curl implementation introduces random bugs on windows builds when the recv fails.
This commit is contained in:
parent
6b6ff393b3
commit
f66d59df03
31
util.c
31
util.c
@ -927,18 +927,6 @@ bool stratum_send(struct pool *pool, char *s, ssize_t len)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_sock(struct pool *pool)
|
|
||||||
{
|
|
||||||
size_t n = 0;
|
|
||||||
|
|
||||||
mutex_lock(&pool->stratum_lock);
|
|
||||||
/* Ignore return code of curl_easy_recv since we're just clearing
|
|
||||||
* anything in the socket if it's still alive */
|
|
||||||
curl_easy_recv(pool->stratum_curl, pool->sockbuf, RECVSIZE, &n);
|
|
||||||
mutex_unlock(&pool->stratum_lock);
|
|
||||||
strcpy(pool->sockbuf, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check to see if Santa's been good to you */
|
/* Check to see if Santa's been good to you */
|
||||||
static bool sock_full(struct pool *pool, bool wait)
|
static bool sock_full(struct pool *pool, bool wait)
|
||||||
{
|
{
|
||||||
@ -961,18 +949,29 @@ static bool sock_full(struct pool *pool, bool wait)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clear_sock(struct pool *pool)
|
||||||
|
{
|
||||||
|
ssize_t n;
|
||||||
|
|
||||||
|
mutex_lock(&pool->stratum_lock);
|
||||||
|
do
|
||||||
|
n = recv(pool->sock, pool->sockbuf, RECVSIZE, 0);
|
||||||
|
while (n > 0);
|
||||||
|
mutex_unlock(&pool->stratum_lock);
|
||||||
|
strcpy(pool->sockbuf, "");
|
||||||
|
}
|
||||||
|
|
||||||
/* Peeks at a socket to find the first end of line and then reads just that
|
/* Peeks at a socket to find the first end of line and then reads just that
|
||||||
* from the socket and returns that as a malloced char */
|
* from the socket and returns that as a malloced char */
|
||||||
char *recv_line(struct pool *pool)
|
char *recv_line(struct pool *pool)
|
||||||
{
|
{
|
||||||
ssize_t len, buflen;
|
ssize_t len, buflen;
|
||||||
char *tok, *sret = NULL;
|
char *tok, *sret = NULL;
|
||||||
size_t n = 0;
|
ssize_t n;
|
||||||
|
|
||||||
if (!strstr(pool->sockbuf, "\n")) {
|
if (!strstr(pool->sockbuf, "\n")) {
|
||||||
char s[RBUFSIZE];
|
char s[RBUFSIZE];
|
||||||
size_t sspace;
|
size_t sspace;
|
||||||
CURLcode rc;
|
|
||||||
|
|
||||||
if (!sock_full(pool, true)) {
|
if (!sock_full(pool, true)) {
|
||||||
applog(LOG_DEBUG, "Timed out waiting for data on sock_full");
|
applog(LOG_DEBUG, "Timed out waiting for data on sock_full");
|
||||||
@ -981,10 +980,10 @@ char *recv_line(struct pool *pool)
|
|||||||
memset(s, 0, RBUFSIZE);
|
memset(s, 0, RBUFSIZE);
|
||||||
|
|
||||||
mutex_lock(&pool->stratum_lock);
|
mutex_lock(&pool->stratum_lock);
|
||||||
rc = curl_easy_recv(pool->stratum_curl, s, RECVSIZE, &n);
|
n = recv(pool->sock, s, RECVSIZE, 0);
|
||||||
mutex_unlock(&pool->stratum_lock);
|
mutex_unlock(&pool->stratum_lock);
|
||||||
|
|
||||||
if (rc != CURLE_OK) {
|
if (n < 1 && errno != EAGAIN) {
|
||||||
applog(LOG_DEBUG, "Failed to recv sock in recv_line");
|
applog(LOG_DEBUG, "Failed to recv sock in recv_line");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user