add_socket.1_9.patch

Greg Hazel, 06/19/2011 10:35 PM

Download (1.29 KB)

View differences:

include/ruby/win32.h (working copy)
235 235
extern rb_pid_t  rb_w32_pipe_exec(const char *, const char *, int, int *, int *);
236 236
extern int    flock(int fd, int oper);
237 237
extern int    rb_w32_has_cancel_io(void);
238
extern int    rb_w32_add_socket(SOCKET, int);
239
extern void   rb_w32_remove_socket(int);
238 240
extern int    rb_w32_is_socket(int);
239 241
extern int    WSAAPI rb_w32_accept(int, struct sockaddr *, int *);
240 242
extern int    WSAAPI rb_w32_bind(int, const struct sockaddr *, int);
win32/win32.c (working copy)
2177 2177
}
2178 2178
#endif
2179 2179

  
2180
int
2181
rb_w32_add_socket(SOCKET sock, int flag)
2182
{
2183
    int fd = rb_w32_open_osfhandle(sock, O_RDWR|O_BINARY|O_NOINHERIT);
2184
    if (fd != -1) {
2185
        st_insert(socklist, (st_data_t)sock, (st_data_t)flag);
2186
    }
2187
    return fd;
2188
}
2189

  
2190
void
2191
rb_w32_remove_socket(int fd)
2192
{
2193
    SOCKET sock = TO_SOCKET(fd);
2194
    st_data_t key = (st_data_t)sock;
2195
    st_delete(socklist, &key, NULL);
2196
    _set_osfhnd(fd, (SOCKET)INVALID_HANDLE_VALUE);
2197
    _close(fd);
2198
}
2199

  
2180 2200
#undef getsockopt
2181 2201

  
2182 2202
static int