Commit 4ec0a88f authored by Scott Vokes's avatar Scott Vokes
Browse files

bus: optionally return stored socket udata when releasing connection.

parent 22839298
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -448,7 +448,7 @@ cleanup:
}

/* Free metadata about a socket that has been disconnected. */
bool bus_release_socket(struct bus *b, int fd) {
bool bus_release_socket(struct bus *b, int fd, void **socket_udata_out) {
    int l_id = listener_id_of_socket(b, fd);

    BUS_LOG_SNPRINTF(b, 2, LOG_SOCKET_REGISTERED, b->udata, 64,
@@ -462,7 +462,7 @@ bool bus_release_socket(struct bus *b, int fd) {
    }

    bool completed = poll_on_completion(b, completion_fd);
    if (!completed) {
    if (!completed) {           /* listener hung up while waiting */
        return false;
    }

@@ -476,6 +476,8 @@ bool bus_release_socket(struct bus *b, int fd) {
    connection_info *ci = (connection_info *)old_value;
    assert(ci != NULL);

    if (socket_udata_out) { *socket_udata_out = ci->udata; }

    bool res = false;

    if (ci->ssl == BUS_NO_SSL) {
@@ -484,7 +486,6 @@ bool bus_release_socket(struct bus *b, int fd) {
        res = bus_ssl_disconnect(b, ci->ssl);
    }

    /* TODO: return ci->udata? */
    free(ci);
    return res;
}
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ const char *bus_log_event_str(log_event_t event);
bool bus_register_socket(struct bus *b, bus_socket_t type, int fd, void *socket_udata);

/* Free metadata about a socket that has been disconnected. */
bool bus_release_socket(struct bus *b, int fd);
bool bus_release_socket(struct bus *b, int fd, void **socket_udata_out);

/* Begin shutting the system down. Returns true once everything pending
 * has resolved. */
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ KineticStatus KineticSession_Disconnect(KineticSession const * const session)
    }
    
    // Close the connection
    bus_release_socket(connection->messageBus, connection->socket);
    bus_release_socket(connection->messageBus, connection->socket, NULL);
    free(connection->si);
    connection->si = NULL;
    connection->socket = KINETIC_HANDLE_INVALID;