コード例 #1
0
ファイル: commands.c プロジェクト: asvetlov/zerogw
void recv_command(struct ev_loop *loop, struct ev_io *io, int rev) {
    ADEBUG(!(rev & EV_ERROR));
    void *sock = SHIFT(io, config_zmqsocket_t, _watch)->_sock;
    while(TRUE) {
        Z_SEQ_INIT(msg, sock);
        Z_RECV_START(msg, break);
        size_t len;
        while(TRUE) {
            len = zmq_msg_size(&msg);
            REPLY_COMMAND(sock, msg, TRUE);
            if(!len) break;
            Z_RECV(msg);
        }
        Z_RECV(msg);
        len = zmq_msg_size(&msg);
        char *data = zmq_msg_data(&msg);
        LDEBUG("Got command `%.*s`", len, data);
        if COMMAND(list_commands) {
            // Keep alphabetically sorted
            REPLY_SHORT(sock, msg, "get_statistics", TRUE);
            REPLY_SHORT(sock, msg, "list_commands", TRUE);
            REPLY_SHORT(sock, msg, "pause_websockets", TRUE);
            REPLY_SHORT(sock, msg, "resume_websockets", FALSE);
        } else if COMMAND(get_statistics) {
            char buf[4096];
            len = format_statistics(buf);
            SNIMPL(zmq_msg_init_size(&msg, len));
            memcpy(zmq_msg_data(&msg), buf, len);
            REPLY_COMMAND(sock, msg, FALSE);
        } else if COMMAND(pause_websockets) {
コード例 #2
0
ファイル: commands.c プロジェクト: Maasik/zerogw
void recv_command(struct ev_loop *loop, struct ev_io *io, int rev) {
    ADEBUG(!(rev & EV_ERROR));
    void *sock = SHIFT(io, config_zmqsocket_t, _watch)->_sock;
    while(TRUE) {
        Z_SEQ_INIT(msg, sock);
        Z_RECV_START(msg, break);
        size_t len;
        while(TRUE) {
            len = zmq_msg_size(&msg);
            REPLY_COMMAND(sock, msg, TRUE);
            if(!len) break;
            Z_RECV_NEXT(msg);
        }
        Z_RECV(msg);
        len = zmq_msg_size(&msg);
        char *data = zmq_msg_data(&msg);
        LDEBUG("Got command `%.*s`", len, data);
        if COMMAND(list_commands) {
            // Keep alphabetically sorted
            REPLY_SHORT(sock, msg, "list_commands", TRUE);
            REPLY_SHORT(sock, msg, "pause_websockets", TRUE);
            REPLY_SHORT(sock, msg, "resume_websockets", TRUE);
            REPLY_SHORT(sock, msg, "sync_now", TRUE);
            REPLY_SHORT(sock, msg, "reopen_logs", FALSE);
        } else if COMMAND(pause_websockets) {
            LWARN("Pausing websockets because of command");
            pause_websockets(TRUE);
            REPLY_SHORT(sock, msg, "paused", FALSE);
        } else if COMMAND(resume_websockets) {