genode/libports/src/lib/lwip/libc_select_notify.patch

40 lines
1.3 KiB
Diff

--- lwip-STABLE-1_4_1-RC1/src/api/sockets.c.orig
+++ lwip-STABLE-1_4_1-RC1/src/api/sockets.c
@@ -171,6 +171,9 @@ static const int err_to_errno_table[] = {
set_errno(sk->err); \
} while (0)
+/* function to notify libc about a socket event */
+extern void (*libc_select_notify)();
+
/* Forward delcaration of some functions */
static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len);
static void lwip_getsockopt_internal(void *arg);
@@ -1244,7 +1247,7 @@ return_copy_fdsets:
* Processes recvevent (data available) and wakes up tasks waiting for select.
*/
static void
-event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
+orig_event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
{
int s;
struct lwip_sock *sock;
@@ -1359,6 +1362,17 @@ again:
SYS_ARCH_UNPROTECT(lev);
}
+/* Wrapper for the original event_callback() function that additionally calls
+ * libc_select_notify()
+ */
+static void
+event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
+{
+ orig_event_callback(conn, evt, len);
+ if (libc_select_notify)
+ libc_select_notify();
+}
+
/**
* Unimplemented: Close one end of a full-duplex connection.
* Currently, the full connection is closed.