close

網路上好像都沒有在講Linux對於select的exceptfd的行為

Windows上面的行為在msdn上面定義是

exceptfds:

  • If processing a connect call (nonblocking), connection attempt failed.
  • OOB data is available for reading (only if SO_OOBINLINE is disabled).

Linux上面的實作是只吃poll回來的POLLPRI

http://lxr.free-electrons.com/source/fs/select.c#L384

463                                         if ((mask & POLLIN_SET) && (in & bit)) {
464                                                 res_in |= bit;
465                                                 retval++;
466                                                 wait->_qproc = NULL;
467                                         }
468                                         if ((mask & POLLOUT_SET) && (out & bit)) {
469                                                 res_out |= bit;
470                                                 retval++;
471                                                 wait->_qproc = NULL;
472                                         }
473                                         if ((mask & POLLEX_SET) && (ex & bit)) {
474                                                 res_ex |= bit;
475                                                 retval++;
476                                                 wait->_qproc = NULL;
477                                         }
384 #define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR)
385 #define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR)
386 #define POLLEX_SET (POLLPRI)

tcp 的poll實做是

http://lxr.free-electrons.com/source/net/ipv4/tcp.c#L432

517                 if (tp->urg_data & TCP_URG_VALID)
518                         mask |= POLLPRI;

所以Linux tcp的select()exceptfds只會有urgent data的部分, 其他的我就懶得找了

arrow
arrow
    全站熱搜

    name 發表在 痞客邦 留言(0) 人氣()