Minor bugfixes after testing
- fix binary search args order - fix missing pollcat_dump() if POLLCAT_DEBUG=0 - safety check on null fp if stderr/stdout closed
This commit is contained in:
@@ -133,7 +133,7 @@ static struct pollfd *pollcat_search (int fd)
|
|||||||
|
|
||||||
/* Do binary search and cache result */
|
/* Do binary search and cache result */
|
||||||
key.fd = fd;
|
key.fd = fd;
|
||||||
ret = bsearch(&key, pollcat_list, sizeof(struct pollfd), pollcat_used, pollcat_comp);
|
ret = bsearch(&key, pollcat_list, pollcat_used, sizeof(struct pollfd), pollcat_comp);
|
||||||
pollcat_last = ret ? ret - pollcat_list : -1;
|
pollcat_last = ret ? ret - pollcat_list : -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -336,15 +336,19 @@ static const char *pollcat_bits (short int events)
|
|||||||
|
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void pollcat_dump (FILE *fp)
|
void pollcat_dump (FILE *fp)
|
||||||
{
|
{
|
||||||
|
#if POLLCAT_DEBUG
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ( !fp && stderr )
|
if ( !fp && stderr )
|
||||||
fp = stderr;
|
fp = stderr;
|
||||||
if ( !fp && stdout )
|
if ( !fp && stdout )
|
||||||
fp = stdout;
|
fp = stdout;
|
||||||
|
if ( !fp )
|
||||||
|
return;
|
||||||
|
|
||||||
fprintf(fp, "pollcat: list %p, used %zu / size %zu\n",
|
fprintf(fp, "pollcat: list %p, used %zu / size %zu\n",
|
||||||
pollcat_list, pollcat_used, pollcat_size);
|
pollcat_list, pollcat_used, pollcat_size);
|
||||||
@@ -365,6 +369,6 @@ void pollcat_dump (FILE *fp)
|
|||||||
|
|
||||||
fprintf(fp, "%-8s %s\n", pollcat_bits(pollcat_list[i].revents), link);
|
fprintf(fp, "%-8s %s\n", pollcat_bits(pollcat_list[i].revents), link);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user