Cygwin: delete /dev/kmsg and thus fhandler_mailslot without substitution

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2018-03-25 12:38:14 +02:00
parent 4fe086c84f
commit 23b5ecdaf3
13 changed files with 623 additions and 1042 deletions

View File

@@ -1724,121 +1724,3 @@ fhandler_windows::select_except (select_stuff *ss)
s->windows_handle = true;
return s;
}
static int
peek_mailslot (select_record *me, bool)
{
HANDLE h;
set_handle_or_return_if_not_open (h, me);
if (me->read_selected && me->read_ready)
return 1;
DWORD msgcnt = 0;
if (!GetMailslotInfo (h, NULL, NULL, &msgcnt, NULL))
{
me->except_ready = true;
select_printf ("mailslot %d(%p) error %E", me->fd, h);
return 1;
}
if (msgcnt > 0)
{
me->read_ready = true;
select_printf ("mailslot %d(%p) ready", me->fd, h);
return 1;
}
select_printf ("mailslot %d(%p) not ready", me->fd, h);
return 0;
}
static int
verify_mailslot (select_record *me, fd_set *rfds, fd_set *wfds,
fd_set *efds)
{
return peek_mailslot (me, true);
}
static int start_thread_mailslot (select_record *me, select_stuff *stuff);
static DWORD WINAPI
thread_mailslot (void *arg)
{
select_mailslot_info *mi = (select_mailslot_info *) arg;
bool gotone = false;
DWORD sleep_time = 0;
for (;;)
{
select_record *s = mi->start;
while ((s = s->next))
if (s->startup == start_thread_mailslot)
{
if (peek_mailslot (s, true))
gotone = true;
if (mi->stop_thread)
{
select_printf ("stopping");
goto out;
}
}
/* Paranoid check */
if (mi->stop_thread)
{
select_printf ("stopping from outer loop");
break;
}
if (gotone)
break;
Sleep (sleep_time >> 3);
if (sleep_time < 80)
++sleep_time;
}
out:
return 0;
}
static int
start_thread_mailslot (select_record *me, select_stuff *stuff)
{
if (stuff->device_specific_mailslot)
{
me->h = *((select_mailslot_info *) stuff->device_specific_mailslot)->thread;
return 1;
}
select_mailslot_info *mi = new select_mailslot_info;
mi->start = &stuff->start;
mi->stop_thread = false;
mi->thread = new cygthread (thread_mailslot, mi, "mailsel");
me->h = *mi->thread;
if (!me->h)
return 0;
stuff->device_specific_mailslot = mi;
return 1;
}
static void
mailslot_cleanup (select_record *, select_stuff *stuff)
{
select_mailslot_info *mi = (select_mailslot_info *) stuff->device_specific_mailslot;
if (!mi)
return;
if (mi->thread)
{
mi->stop_thread = true;
mi->thread->detach ();
}
delete mi;
stuff->device_specific_mailslot = NULL;
}
select_record *
fhandler_mailslot::select_read (select_stuff *ss)
{
select_record *s = ss->start.next;
s->startup = start_thread_mailslot;
s->peek = peek_mailslot;
s->verify = verify_mailslot;
s->cleanup = mailslot_cleanup;
s->read_selected = true;
s->read_ready = false;
return s;
}