On Tue, 2013-01-22 at 20:37 +0100, Svante Signell wrote:
> On Tue, 2013-01-22 at 19:01 +0100, Samuel Thibault wrote:
> > Svante Signell, le Tue 22 Jan 2013 18:53:43 +0100, a écrit :
> > > Attached is the first patch for a 3-way split of hurdselect.c into three
> > > cases: DELAY, POLL, SELECT leading to a more POSIX conforming POLL.
> >
> > It is way more readable that the previous versions :)
> >
> > > + if (nfds > _hurd_dtablesize)
> > > + nfds = _hurd_dtablesize;
> >
> > You can't afford moving that to the general case: in the poll case, nfds
> > is not the maximum of the fds, but the number of elements in the array,
> > which can be very big, if the application puts the same fd several time
> > in the array.
>
> I did update the patch but it was not included in the attachment (same
> problem with Pinos comment on fd < _hurd_tablesize) sorry.
Updated patch attached (not reindented). Shall I continue sending
patches or not?
And what about submitting to debian-hurd instead of bug-hurd?
--- hurdselect.c-38+patches 2013-01-22 16:09:25.000000000 +0100
+++ hurdselect_step1_1.c 2013-01-22 18:50:19.000000000 +0100
@@ -68,6 +68,65 @@ _hurd_select (int nfds,
assert (sizeof (union typeword) == sizeof (mach_msg_type_t));
assert (sizeof (uint32_t) == sizeof (mach_msg_type_t));
+ enum {
+ DELAY = -1,
+ SELECT = 0,
+ POLL = 1
+ } ispoll;
+
+ if (nfds == 0)
+ ispoll = DELAY;
+ else if (pollfds)
+ ispoll = POLL;
+ else
+ ispoll = SELECT;
+
+ union
+ {
+ mach_msg_header_t head;
+#ifdef MACH_MSG_TRAILER_MINIMUM_SIZE
+ struct
+ {
+ mach_msg_header_t head;
+ NDR_record_t ndr;
+ error_t err;
+ } error;
+ struct
+ {
+ mach_msg_header_t head;
+ NDR_record_t ndr;
+ error_t err;
+ int result;
+ mach_msg_trailer_t trailer;
+ } success;
+#else
+ struct
+ {
+ mach_msg_header_t head;
+ union typeword err_type;
+ error_t err;
+ } error;
+ struct
+ {
+ mach_msg_header_t head;
+ union typeword err_type;
+ error_t err;
+ union typeword result_type;
+ int result;
+ } success;
+#endif
+ } msg;
+ mach_msg_option_t options = (timeout == NULL ? 0 : MACH_RCV_TIMEOUT);
+ error_t msgerr;
+
+#define IO_SELECT_REPLY_MSGID (21012 + 100) /* XXX */
+#ifdef MACH_MSG_TYPE_BIT
+ const union typeword inttype =
+ { type:
+ { MACH_MSG_TYPE_INTEGER_T, sizeof (integer_t) * 8, 1, 1, 0, 0 }
+ };
+#endif
+
if (nfds < 0 || nfds > FD_SETSIZE)
{
errno = EINVAL;
@@ -296,57 +355,12 @@ _hurd_select (int nfds,
{
/* Now wait for io_select_reply messages on PORT,
timing out as appropriate. */
-
- union
- {
- mach_msg_header_t head;
-#ifdef MACH_MSG_TRAILER_MINIMUM_SIZE
- struct
- {
- mach_msg_header_t head;
- NDR_record_t ndr;
- error_t err;
- } error;
- struct
- {
- mach_msg_header_t head;
- NDR_record_t ndr;
- error_t err;
- int result;
- mach_msg_trailer_t trailer;
- } success;
-#else
- struct
- {
- mach_msg_header_t head;
- union typeword err_type;
- error_t err;
- } error;
- struct
- {
- mach_msg_header_t head;
- union typeword err_type;
- error_t err;
- union typeword result_type;
- int result;
- } success;
-#endif
- } msg;
- mach_msg_option_t options = (timeout == NULL ? 0 : MACH_RCV_TIMEOUT);
- error_t msgerr;
while ((msgerr = __mach_msg (&msg.head,
MACH_RCV_MSG | MACH_RCV_INTERRUPT | options,
0, sizeof msg, portset, to,
MACH_PORT_NULL)) == MACH_MSG_SUCCESS)
{
/* We got a message. Decode it. */
-#define IO_SELECT_REPLY_MSGID (21012 + 100) /* XXX */
-#ifdef MACH_MSG_TYPE_BIT
- const union typeword inttype =
- { type:
- { MACH_MSG_TYPE_INTEGER_T, sizeof (integer_t) * 8, 1, 1, 0, 0 }
- };
-#endif
if (msg.head.msgh_id == IO_SELECT_REPLY_MSGID &&
msg.head.msgh_size >= sizeof msg.error &&
!(msg.head.msgh_bits & MACH_MSGH_BITS_COMPLEX) &&