glusterfs 4.0.1 rpc analysis note 2 (socket.so module)

socket.c defines a set of structure functions at line 4000. We can find the entry from here. If it is a client, we need to call connect.

If it is a server, you need to call listen,

struct rpc_transport_ops tops =
{
        .listen             = socket_listen,
        .connect            = socket_connect,
        .disconnect         = socket_disconnect,
        .submit_request     = socket_submit_request,
        .submit_reply       = socket_submit_reply,
        .get_peername       = socket_getpeername,
        .get_peeraddr       = socket_getpeeraddr,
        .get_myname         = socket_getmyname,
        .get_myaddr         = socket_getmyaddr,
        .throttle           = socket_throttle,
};

 At line 3541 of the connect function, add the socket to the monitoring range of the eventpool,

    priv->idx = event_register (ctx->event_pool, priv->sock,
                                                    socket_event_handler,
                                                    this, 1, 1);               

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324751459&siteId=291194637