Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/mpl/bind/dist/lib/isc/unix cleanup unused stuff now...



details:   https://anonhg.NetBSD.org/src/rev/f7939ed0389d
branches:  trunk
changeset: 448887:f7939ed0389d
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Feb 13 01:16:30 2019 +0000

description:
cleanup unused stuff now that we execute directly and not in a separate task.

diffstat:

 external/mpl/bind/dist/lib/isc/unix/socket.c |  167 ++++----------------------
 1 files changed, 28 insertions(+), 139 deletions(-)

diffs (truncated from 302 to 300 lines):

diff -r 7345255c3ffb -r f7939ed0389d external/mpl/bind/dist/lib/isc/unix/socket.c
--- a/external/mpl/bind/dist/lib/isc/unix/socket.c      Tue Feb 12 21:41:38 2019 +0000
+++ b/external/mpl/bind/dist/lib/isc/unix/socket.c      Wed Feb 13 01:16:30 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: socket.c,v 1.6 2019/02/12 02:38:55 christos Exp $      */
+/*     $NetBSD: socket.c,v 1.7 2019/02/13 01:16:30 christos Exp $      */
 
 /*
  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
@@ -351,14 +351,6 @@
        char                            name[16];
        void *                          tag;
 
-       /*
-        * Internal events.  Posted when a descriptor is readable or
-        * writable.  These are statically allocated and never freed.
-        * They will be set to non-purgable before use.
-        */
-       intev_t                 readable_ev;
-       intev_t                 writable_ev;
-
        ISC_LIST(isc_socketevent_t)             send_list;
        ISC_LIST(isc_socketevent_t)             recv_list;
        ISC_LIST(isc_socket_newconnev_t)        accept_list;
@@ -366,9 +358,7 @@
 
        isc_sockaddr_t          peer_address;       /* remote address */
 
-       unsigned int            pending_recv : 1,
-                               pending_send : 1,
-                               listener : 1,       /* listener socket */
+       unsigned int            listener : 1,       /* listener socket */
                                connected : 1,
                                connecting : 1,     /* connect pending */
                                bound : 1,          /* bound to local addr */
@@ -380,10 +370,10 @@
        unsigned char           overflow; /* used for MSG_TRUNC fake */
 #endif
 
-        void                    *fdwatcharg;    
-        isc_sockfdwatch_t       fdwatchcb;
-        int                     fdwatchflags;
-        isc_task_t              *fdwatchtask;
+       void                    *fdwatcharg;
+       isc_sockfdwatch_t       fdwatchcb;
+       int                     fdwatchflags;
+       isc_task_t              *fdwatchtask;
        unsigned int            dscp;
 };
 
@@ -474,8 +464,8 @@
 static void internal_connect(isc__socket_t *);
 static void internal_recv(isc__socket_t *);
 static void internal_send(isc__socket_t *);
-static void internal_fdwatch_write(isc_task_t *, isc_event_t *);
-static void internal_fdwatch_read(isc_task_t *, isc_event_t *);
+static void internal_fdwatch_write(isc__socket_t *);
+static void internal_fdwatch_read(isc__socket_t *);
 static void process_cmsg(isc__socket_t *, struct msghdr *, isc_socketevent_t *);
 static void build_msghdr_send(isc__socket_t *, char *, isc_socketevent_t *,
                              struct msghdr *, struct iovec *, size_t *);
@@ -1962,8 +1952,6 @@
        ISC_LIST_INIT(sock->accept_list);
        ISC_LIST_INIT(sock->connect_list);
        sock->listener = 0;
-       sock->pending_recv = 0;
-       sock->pending_send = 0;
        sock->connected = 0;
        sock->connecting = 0;
        sock->bound = 0;
@@ -1974,16 +1962,6 @@
         */
        isc_mutex_init(&sock->lock);
 
-       /*
-        * Initialize readable and writable events.
-        */
-       ISC_EVENT_INIT(&sock->readable_ev, sizeof(intev_t),
-                      ISC_EVENTATTR_NOPURGE, NULL, ISC_SOCKEVENT_INTR,
-                      NULL, sock, sock, NULL, NULL);
-       ISC_EVENT_INIT(&sock->writable_ev, sizeof(intev_t),
-                      ISC_EVENTATTR_NOPURGE, NULL, ISC_SOCKEVENT_INTW,
-                      NULL, sock, sock, NULL, NULL);
-
        sock->common.magic = ISCAPI_SOCKET_MAGIC;
        sock->common.impmagic = SOCKET_MAGIC;
        *socketp = sock;
@@ -2005,8 +1983,6 @@
        INSIST(VALID_SOCKET(sock));
        INSIST(isc_refcount_current(&sock->references) == 0);
        INSIST(!sock->connecting);
-       INSIST(!sock->pending_recv);
-       INSIST(!sock->pending_send);
        INSIST(ISC_LIST_EMPTY(sock->recv_list));
        INSIST(ISC_LIST_EMPTY(sock->send_list));
        INSIST(ISC_LIST_EMPTY(sock->accept_list));
@@ -2820,8 +2796,6 @@
        REQUIRE(sock->fd >= 0 && sock->fd < (int)sock->manager->maxsocks);
 
        INSIST(!sock->connecting);
-       INSIST(!sock->pending_recv);
-       INSIST(!sock->pending_send);
        INSIST(ISC_LIST_EMPTY(sock->recv_list));
        INSIST(ISC_LIST_EMPTY(sock->send_list));
        INSIST(ISC_LIST_EMPTY(sock->accept_list));
@@ -2849,64 +2823,22 @@
        return (ISC_R_SUCCESS);
 }
 
-/*
- * I/O is possible on a given socket.  Schedule an event to this task that
- * will call an internal function to do the I/O.  This will charge the
- * task with the I/O operation and let our select loop handler get back
- * to doing something real as fast as possible.
- *
- * The socket and manager must be locked before calling this function.
- */
 static void
 dispatch_recv(isc__socket_t *sock) {
-       intev_t *iev;
-       isc_task_t *sender;
-
        if (sock->type != isc_sockettype_fdwatch) {
                internal_recv(sock);
-               return;
-       }
-
-       LOCK(&sock->lock);
-       INSIST(!sock->pending_recv);
-
-       sender = sock->fdwatchtask;
-       sock->pending_recv = 1;
-       iev = &sock->readable_ev;
-
-       isc_refcount_increment(&sock->references);
-       iev->ev_sender = sock;
-       iev->ev_action = internal_fdwatch_read;
-       iev->ev_arg = sock;
-       UNLOCK(&sock->lock);
-       internal_fdwatch_read(sender, iev);
+       } else {
+               internal_fdwatch_read(sock);
+       }
 }
 
 static void
 dispatch_send(isc__socket_t *sock) {
-       intev_t *iev;
-       isc_task_t *sender;
-
        if (sock->type != isc_sockettype_fdwatch) {
                internal_send(sock);
-               return;
-       }
-
-       LOCK(&sock->lock);
-
-       INSIST(!sock->pending_send);
-
-       sender = sock->fdwatchtask;
-       sock->pending_send = 1;
-       iev = &sock->writable_ev;
-
-       isc_refcount_increment(&sock->references);
-       iev->ev_sender = sock;
-       iev->ev_action = internal_fdwatch_write;
-       iev->ev_arg = sock;
-
-       UNLOCK(&sock->lock);
-       internal_fdwatch_write(sender, iev);
+       } else {
+               internal_fdwatch_write(sock);
+       }
 }
 
 /*
@@ -3347,32 +3279,21 @@
 }
 
 static void
-internal_fdwatch_write(isc_task_t *me, isc_event_t *ev) {
-       isc__socket_t *sock;
+internal_fdwatch_write(isc__socket_t *sock)
+{
        int more_data;
 
-       INSIST(ev->ev_type == ISC_SOCKEVENT_INTW);
-
-       /*
-        * Find out what socket this is and lock it.
-        */
-       sock = (isc__socket_t *)ev->ev_sender;
        INSIST(VALID_SOCKET(sock));
 
        LOCK(&sock->lock);
-       socket_log(sock, NULL, IOEVENT,
-                  isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_INTERNALSEND,
-                  "internal_fdwatch_write: task %p got event %p", me, ev);
-
-       INSIST(sock->pending_send == 1);
-
+       isc_refcount_increment(&sock->references);
        UNLOCK(&sock->lock);
-       more_data = (sock->fdwatchcb)(me, (isc_socket_t *)sock,
+
+       more_data = (sock->fdwatchcb)(sock->fdwatchtask, (isc_socket_t *)sock,
                                      sock->fdwatcharg, ISC_SOCKFDWATCH_WRITE);
+
        LOCK(&sock->lock);
 
-       sock->pending_send = 0;
-
        if (isc_refcount_decrement(&sock->references) == 0) {
                UNLOCK(&sock->lock);
                destroy(&sock);
@@ -3387,31 +3308,21 @@
 }
 
 static void
-internal_fdwatch_read(isc_task_t *me, isc_event_t *ev) {
-       isc__socket_t *sock;
+internal_fdwatch_read(isc__socket_t *sock)
+{
        int more_data;
 
-       INSIST(ev->ev_type == ISC_SOCKEVENT_INTR);
-
-       /*
-        * Find out what socket this is and lock it.
-        */
-       sock = (isc__socket_t *)ev->ev_sender;
        INSIST(VALID_SOCKET(sock));
 
        LOCK(&sock->lock);
-       socket_log(sock, NULL, IOEVENT,
-                  isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_INTERNALRECV,
-                  "internal_fdwatch_read: task %p got event %p", me, ev);
-
-       INSIST(sock->pending_recv == 1);
-
+       isc_refcount_increment(&sock->references);
        UNLOCK(&sock->lock);
-       more_data = (sock->fdwatchcb)(me, (isc_socket_t *)sock,
+
+       more_data = (sock->fdwatchcb)(sock->fdwatchtask, (isc_socket_t *)sock,
                                      sock->fdwatcharg, ISC_SOCKFDWATCH_READ);
+
        LOCK(&sock->lock);
 
-       sock->pending_recv = 0;
        if (isc_refcount_decrement(&sock->references) == 0) {
                UNLOCK(&sock->lock);
                destroy(&sock);
@@ -5759,14 +5670,6 @@
                }
 
                TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "states"));
-               if (sock->pending_recv)
-                       TRY0(xmlTextWriterWriteElement(writer,
-                                               ISC_XMLCHAR "state",
-                                               ISC_XMLCHAR "pending-receive"));
-               if (sock->pending_send)
-                       TRY0(xmlTextWriterWriteElement(writer,
-                                                 ISC_XMLCHAR "state",
-                                                 ISC_XMLCHAR "pending-send"));
                if (sock->listener)
                        TRY0(xmlTextWriterWriteElement(writer,
                                                       ISC_XMLCHAR "state",
@@ -5875,18 +5778,6 @@
                CHECKMEM(states);
                json_object_object_add(entry, "states", states);
 
-               if (sock->pending_recv) {
-                       obj = json_object_new_string("pending-receive");
-                       CHECKMEM(obj);
-                       json_object_array_add(states, obj);
-               }
-
-               if (sock->pending_send) {
-                       obj = json_object_new_string("pending-send");
-                       CHECKMEM(obj);
-                       json_object_array_add(states, obj);
-               }
-
                if (sock->listener) {
                        obj = json_object_new_string("listener");
                        CHECKMEM(obj);
@@ -6042,12 +5933,10 @@
 
        if ((flags & (ISC_SOCKFDWATCH_READ | ISC_SOCKFDWATCH_WRITE)) != 0) {
                LOCK(&sock->lock);
-               if (((flags & ISC_SOCKFDWATCH_READ) != 0) &&
-                   !sock->pending_recv)
+               if ((flags & ISC_SOCKFDWATCH_READ) != 0)
                        select_poke(sock->manager, sock->threadid, sock->fd,
                                    SELECT_POKE_READ);
-               if (((flags & ISC_SOCKFDWATCH_WRITE) != 0) &&
-                   !sock->pending_send)
+               if ((flags & ISC_SOCKFDWATCH_WRITE) != 0)
                        select_poke(sock->manager, sock->threadid, sock->fd,



Home | Main Index | Thread Index | Old Index