mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
[PATCH] WL#3704 mgmapi timeouts: Fix infinite (0) timeout for ndb_logevent_get_next
Index: ndb-work/storage/ndb/src/mgmapi/ndb_logevent.cpp =================================================================== storage/ndb/src/mgmapi/ndb_logevent.cpp: WL#3704 mgmapi timeouts: Fix infinite (0) timeout for ndb_logevent_get_next
This commit is contained in:
parent
7e00600a40
commit
fd4862cf23
1 changed files with 12 additions and 19 deletions
|
@ -389,14 +389,18 @@ int ndb_logevent_get_next(const NdbLogEventHandle h,
|
|||
struct ndb_logevent *dst,
|
||||
unsigned timeout_in_milliseconds)
|
||||
{
|
||||
if (timeout_in_milliseconds == 0)
|
||||
{
|
||||
int res;
|
||||
while ((res = ndb_logevent_get_next(h, dst, 60000))==0);
|
||||
return res;
|
||||
}
|
||||
|
||||
SocketInputStream in(h->socket, timeout_in_milliseconds);
|
||||
|
||||
Properties p;
|
||||
char buf[256];
|
||||
|
||||
struct timeval start_time;
|
||||
gettimeofday(&start_time, 0);
|
||||
|
||||
/* header */
|
||||
while (1) {
|
||||
if (in.gets(buf,sizeof(buf)) == 0)
|
||||
|
@ -409,24 +413,15 @@ int ndb_logevent_get_next(const NdbLogEventHandle h,
|
|||
// timed out
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( strcmp("log event reply\n", buf) == 0 )
|
||||
break;
|
||||
|
||||
if ( strcmp("<PING>\n", buf) )
|
||||
ndbout_c("skipped: %s", buf);
|
||||
|
||||
struct timeval now;
|
||||
gettimeofday(&now, 0);
|
||||
unsigned elapsed_ms= (now.tv_sec-start_time.tv_sec)*1000 +
|
||||
((signed int)now.tv_usec-(signed int)start_time.tv_usec)/1000;
|
||||
|
||||
if (elapsed_ms >= timeout_in_milliseconds)
|
||||
{
|
||||
// timed out
|
||||
return 0;
|
||||
}
|
||||
|
||||
new (&in) SocketInputStream(h->socket, timeout_in_milliseconds-elapsed_ms);
|
||||
if(in.timedout())
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* read name-value pairs into properties object */
|
||||
|
@ -437,11 +432,9 @@ int ndb_logevent_get_next(const NdbLogEventHandle h,
|
|||
h->m_error= NDB_LEH_READ_ERROR;
|
||||
return -1;
|
||||
}
|
||||
if ( buf[0] == 0 )
|
||||
{
|
||||
// timed out
|
||||
if (in.timedout())
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( buf[0] == '\n' )
|
||||
{
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue