Example #1
0
static int connection(void)
{
    pid_t pid = getpid();
    if(pid != thread_state.pid) {
        int fd = connect_master();
        if(-1 == fd) return -1;
        thread_state.connection_fd = fd;
        thread_state.pid = pid;
        if(!await_go()) return -1;
    }
    return thread_state.connection_fd;
}
Example #2
0
int client_make_connection(enum need need)
{
    pid_t pid = getpid();
    if(pid != thread_state.pid) {
        int fd = connect_master(need == HOOK ? "HOOK" : "HINT");
        if(-1 == fd) return -1;
        thread_state.connection_fd = fd;
        thread_state.pid = pid;
        thread_state.need = need;
        if(!await_go()) return -1;
    }
    ASSERT(thread_state.need == need);
    return thread_state.connection_fd;
}