diff options
-rw-r--r-- | usr/src/lib/varpd/svp/common/libvarpd_svp.h | 2 | ||||
-rw-r--r-- | usr/src/lib/varpd/svp/common/libvarpd_svp_conn.c | 22 | ||||
-rw-r--r-- | usr/src/lib/varpd/svp/common/libvarpd_svp_loop.c | 12 |
3 files changed, 19 insertions, 17 deletions
diff --git a/usr/src/lib/varpd/svp/common/libvarpd_svp.h b/usr/src/lib/varpd/svp/common/libvarpd_svp.h index 8192b842ce..ea89f0300d 100644 --- a/usr/src/lib/varpd/svp/common/libvarpd_svp.h +++ b/usr/src/lib/varpd/svp/common/libvarpd_svp.h @@ -306,7 +306,7 @@ extern void svp_timer_remove(svp_timer_t *); * Event loop management */ extern int svp_event_associate(svp_event_t *, int); -extern int svp_event_dissociate(svp_event_t *, int); +extern int svp_event_dissociate(int); extern int svp_event_inject(svp_event_t *); /* diff --git a/usr/src/lib/varpd/svp/common/libvarpd_svp_conn.c b/usr/src/lib/varpd/svp/common/libvarpd_svp_conn.c index 4d10d1dba4..3020e4d67f 100644 --- a/usr/src/lib/varpd/svp/common/libvarpd_svp_conn.c +++ b/usr/src/lib/varpd/svp/common/libvarpd_svp_conn.c @@ -654,8 +654,7 @@ svp_conn_reset(svp_conn_t *scp) assert(MUTEX_HELD(&srp->sr_lock)); assert(MUTEX_HELD(&scp->sc_lock)); - assert(svp_event_dissociate(&scp->sc_event, scp->sc_socket) == - ENOENT); + VERIFY(svp_event_dissociate(scp->sc_socket) == ENOENT); if (close(scp->sc_socket) != 0) libvarpd_panic("failed to close socket %d: %d", scp->sc_socket, errno); @@ -854,11 +853,12 @@ svp_conn_querytimer(void *arg) */ scp->sc_flags |= SVP_CF_TEARDOWN; - ret = svp_event_dissociate(&scp->sc_event, scp->sc_socket); - if (ret == 0) + /* + * svp_event_dissociate guarantees either "lose the disassociate" + * (ENOENT) or successful dissociation (0). It panics itself otherwise. + */ + if (svp_event_dissociate(scp->sc_socket) == 0) svp_conn_inject(scp); - else - VERIFY(ret == ENOENT); mutex_exit(&scp->sc_lock); } @@ -979,8 +979,6 @@ svp_conn_create(svp_remote_t *srp, const struct in6_addr *addr) void svp_conn_destroy(svp_conn_t *scp) { - int ret; - mutex_enter(&scp->sc_lock); if (scp->sc_cstate != SVP_CS_ERROR) libvarpd_panic("asked to tear down an active connection"); @@ -991,11 +989,9 @@ svp_conn_destroy(svp_conn_t *scp) libvarpd_panic("asked to remove a connection with non-empty " "query list"); - if ((ret = svp_event_dissociate(&scp->sc_event, scp->sc_socket)) != - ENOENT) { - libvarpd_panic("dissociate failed or was actually " - "associated: %d", ret); - } + if (svp_event_dissociate(scp->sc_socket) == 0) + libvarpd_panic("removed connection was actually associated."); + mutex_exit(&scp->sc_lock); /* Verify our timers are killed */ diff --git a/usr/src/lib/varpd/svp/common/libvarpd_svp_loop.c b/usr/src/lib/varpd/svp/common/libvarpd_svp_loop.c index 18a79b9dff..640077aef6 100644 --- a/usr/src/lib/varpd/svp/common/libvarpd_svp_loop.c +++ b/usr/src/lib/varpd/svp/common/libvarpd_svp_loop.c @@ -104,17 +104,23 @@ svp_event_associate(svp_event_t *sep, int fd) return (ret); } -/* ARGSUSED */ +/* + * Remove a file descriptor from the SVP event port. + * + * This will return either success (0) or already-dissociated (ENOENT). + * We panic here without returning if the underlying system has a problem. + */ int -svp_event_dissociate(svp_event_t *sep, int fd) +svp_event_dissociate(int fd) { int ret; ret = port_dissociate(svp_event.sel_port, PORT_SOURCE_FD, fd); if (ret != 0) { - if (errno != ENOENT) + if (errno != ENOENT) { libvarpd_panic("unexpected port_dissociate error: %d", errno); + } ret = errno; } return (ret); |