Changeset: f18fefe46791 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f18fefe46791
Modified Files:
common/stream/socket_stream.c
Branch: Aug2024
Log Message:
Properly deal with an OOB message: discard data, and OOB mark.
diffs (55 lines):
diff --git a/common/stream/socket_stream.c b/common/stream/socket_stream.c
--- a/common/stream/socket_stream.c
+++ b/common/stream/socket_stream.c
@@ -18,6 +18,7 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
+#include <sys/ioctl.h>
/* ------------------------------------------------------------------ */
@@ -136,6 +137,21 @@ socket_read(stream *restrict s, void *re
return -1;
}
if (ret == 1 && pfd.revents & POLLPRI) {
+ /* discard regular data until OOB mark */
+ for (;;) {
+ int atmark = 0;
+ char flush[100];
+ if (ioctl(s->stream_data.s, SIOCATMARK,
&atmark) < 0) {
+ perror("ioctl");
+ break;
+ }
+ if (atmark)
+ break;
+ if (read(s->stream_data.s, flush,
sizeof(flush)) < 0) {
+ perror("read");
+ break;
+ }
+ }
char b = 0;
switch (recv(s->stream_data.s, &b, 1, MSG_OOB))
{
case 0:
@@ -359,6 +375,21 @@ socket_getoob(const stream *s)
if (!FD_ISSET(fd, &fds))
return 0;
#endif
+ /* discard regular data until OOB mark */
+ for (;;) {
+ int atmark = 0;
+ char flush[100];
+ if (ioctl(fd, SIOCATMARK, &atmark) < 0) {
+ perror("ioctl");
+ break;
+ }
+ if (atmark)
+ break;
+ if (read(fd, flush, sizeof(flush)) < 0) {
+ perror("read");
+ break;
+ }
+ }
char b = 0;
switch (recv(fd, &b, 1, MSG_OOB)) {
case 0:
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]