Annotation of embedaddon/mtr/packet/wait_cygwin.c, revision 1.1.1.1

1.1       misho       1: /*
                      2:     mtr  --  a network diagnostic tool
                      3:     Copyright (C) 2016  Matt Kimball
                      4: 
                      5:     This program is free software; you can redistribute it and/or modify
                      6:     it under the terms of the GNU General Public License version 2 as
                      7:     published by the Free Software Foundation.
                      8: 
                      9:     This program is distributed in the hope that it will be useful,
                     10:     but WITHOUT ANY WARRANTY; without even the implied warranty of
                     11:     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     12:     GNU General Public License for more details.
                     13: 
                     14:     You should have received a copy of the GNU General Public License
                     15:     along with this program; if not, write to the Free Software
                     16:     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                     17: */
                     18: 
                     19: #include "wait.h"
                     20: 
                     21: #include <io.h>
                     22: #include <stdio.h>
                     23: #include <windows.h>
                     24: 
                     25: #include "command.h"
                     26: 
                     27: /*
                     28:     Sleep until we receive a new probe response, a new command on the
                     29:     command stream, or a probe timeout.  On Windows, this means that
                     30:     we will sleep with an alertable wait, as all of these conditions
                     31:     use I/O completion routines as notifications of these events.
                     32: */
                     33: void wait_for_activity(
                     34:     struct command_buffer_t *command_buffer,
                     35:     struct net_state_t *net_state)
                     36: {
                     37:     DWORD wait_result;
                     38: 
                     39:     /*
                     40:        Start the command read overlapped I/O just prior to sleeping.
                     41:        During development of the Cygwin port, there was a bug where the
                     42:        overlapped I/O was started earlier in the mtr-packet loop, and
                     43:        an intermediate alertable wait could leave us in this Sleep
                     44:        without an active command read.  So now we do this here, instead.
                     45:      */
                     46:     start_read_command(command_buffer);
                     47: 
                     48:     /*  Sleep until an I/O completion routine runs  */
                     49:     wait_result = SleepEx(INFINITE, TRUE);
                     50: 
                     51:     if (wait_result == WAIT_FAILED) {
                     52:         fprintf(stderr, "SleepEx failure %d\n", GetLastError());
                     53:         exit(EXIT_FAILURE);
                     54:     }
                     55: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>