rDSN icon indicating copy to clipboard operation
rDSN copied to clipboard

fix fcntl() bug in io_looper

Open qinzuoyan opened this issue 9 years ago • 0 comments

There is a bug in io_looper:

E03:50:47.941 (1452743447941392892 0de8) replica.io-thrd.03560: (s = 33) connect failed (in epoll), err = Connection refused
E03:50:47.941 (1452743447941403737 0de9) replica.io-thrd.03561: (s = 33) connect failed (in epoll), err = Success
E03:50:47.941 (1452743447941424080 0de9) replica.io-thrd.03561: unbind io handler to epoll_wait failed, err = No such file or directory, fd = 33
E03:50:47.941 (1452743447941435396 0de9) replica.io-thrd.03561: error code is not handled, err = ERR_BIND_IOCP_FAILED
W03:50:47.941 (1452743447941434078 0de8) replica.io-thrd.03560: (s = 33) connect failed, err = Software caused connection abort
E03:50:47.941 (1452743447941443184 0de8) replica.io-thrd.03560: unbind io handler to epoll_wait failed, err = No such file or directory, fd = 33
E03:50:47.941 (1452743447941449905 0de8) replica.io-thrd.03560: error code is not handled, err = ERR_BIND_IOCP_FAILED
F03:50:47.941 (1452743447941472688 0de9) replica.io-thrd.03561: assertion expression: flags != -1
F03:50:47.941 (1452743447941478411 0de9) replica.io-thrd.03561: fcntl failed, err = Bad file descriptor, fd = 33

source code:

        error_code io_looper::bind_io_handle(
            dsn_handle_t handle,
            io_loop_callback* cb,
            unsigned int events,
            ref_counter* ctx
            )
        {
            int fd = (int)(intptr_t)(handle);

            int flags = fcntl(fd, F_GETFL, 0);
            dassert (flags != -1, "fcntl failed, err = %s, fd = %d", strerror(errno), fd);

qinzuoyan avatar Jan 18 '16 05:01 qinzuoyan