[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34977 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34977 - in gnunet/src: include util |
Date: |
Sun, 25 Jan 2015 00:01:22 +0100 |
Author: LRN
Date: 2015-01-25 00:01:22 +0100 (Sun, 25 Jan 2015)
New Revision: 34977
Modified:
gnunet/src/include/gnunet_disk_lib.h
gnunet/src/util/disk.c
gnunet/src/util/network.c
Log:
Add support for selecting on W32 events
Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h 2015-01-24 18:53:29 UTC (rev
34976)
+++ gnunet/src/include/gnunet_disk_lib.h 2015-01-24 23:01:22 UTC (rev
34977)
@@ -36,6 +36,11 @@
enum GNUNET_FILE_Type
{
/**
+ * Handle represents an event.
+ */
+ GNUNET_DISK_HANLDE_TYPE_EVENT,
+
+ /**
* Handle represents a file.
*/
GNUNET_DISK_HANLDE_TYPE_FILE,
Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c 2015-01-24 18:53:29 UTC (rev 34976)
+++ gnunet/src/util/disk.c 2015-01-24 23:01:22 UTC (rev 34977)
@@ -854,7 +854,7 @@
#ifdef MINGW
DWORD bytes_read;
- if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
+ if (h->type == GNUNET_DISK_HANLDE_TYPE_FILE)
{
if (!ReadFile (h->h, result, len, &bytes_read, NULL))
{
@@ -862,7 +862,7 @@
return GNUNET_SYSERR;
}
}
- else
+ else if (h->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
{
if (!ReadFile (h->h, result, len, &bytes_read, h->oOverlapRead))
{
@@ -877,6 +877,10 @@
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes from pipe\n", bytes_read);
}
+ else
+ {
+ bytes_read = 0;
+ }
return bytes_read;
#else
return read (h->fd, result, len);
@@ -908,7 +912,7 @@
#ifdef MINGW
DWORD bytes_read;
- if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
+ if (h->type == GNUNET_DISK_HANLDE_TYPE_FILE)
{
if (!ReadFile (h->h, result, len, &bytes_read, NULL))
{
@@ -916,7 +920,7 @@
return GNUNET_SYSERR;
}
}
- else
+ else if (h->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
{
if (!ReadFile (h->h, result, len, &bytes_read, h->oOverlapRead))
{
@@ -937,6 +941,10 @@
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes\n", bytes_read);
}
+ else
+ {
+ bytes_read = 0;
+ }
return bytes_read;
#else
int flags;
@@ -1005,7 +1013,7 @@
#ifdef MINGW
DWORD bytes_written;
- if (h->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
+ if (h->type == GNUNET_DISK_HANLDE_TYPE_FILE)
{
if (!WriteFile (h->h, buffer, n, &bytes_written, NULL))
{
@@ -1013,7 +1021,7 @@
return GNUNET_SYSERR;
}
}
- else
+ else if (h->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "It is a pipe trying to write %u bytes\n",
n);
if (!WriteFile (h->h, buffer, n, &bytes_written, h->oOverlapWrite))
@@ -1062,6 +1070,10 @@
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "Wrote %u bytes\n", bytes_written);
}
+ else
+ {
+ bytes_written = 0;
+ }
return bytes_written;
#else
return write (h->fd, buffer, n);
@@ -1899,6 +1911,15 @@
case FILE_TYPE_PIPE:
ftype = GNUNET_DISK_HANLDE_TYPE_PIPE;
break;
+ case FILE_TYPE_UNKNOWN:
+ if (GetLastError () == NO_ERROR)
+ {
+ if (0 != ResetEvent (osfh))
+ ftype = GNUNET_DISK_HANLDE_TYPE_EVENT;
+ }
+ else
+ return NULL;
+ break;
default:
return NULL;
}
Modified: gnunet/src/util/network.c
===================================================================
--- gnunet/src/util/network.c 2015-01-24 18:53:29 UTC (rev 34976)
+++ gnunet/src/util/network.c 2015-01-24 23:01:22 UTC (rev 34977)
@@ -1725,15 +1725,26 @@
struct GNUNET_DISK_FileHandle *fh;
unsigned int roff;
unsigned int woff;
- int is_pipe;
for (woff = 0, roff = 0; roff < fds->handles_pos; roff++)
{
fh = fds->handles[roff];
- is_pipe = fh->type == GNUNET_DISK_HANLDE_TYPE_PIPE;
- if ((except && is_pipe && pipe_except_ready (fh)) ||
- (!except && (!is_pipe || pipe_read_ready (fh))))
- fds->handles[woff++] = fh;
+ if (fh->type == GNUNET_DISK_HANLDE_TYPE_PIPE)
+ {
+ if ((except && pipe_except_ready (fh)) ||
+ (!except && pipe_read_ready (fh)))
+ fds->handles[woff++] = fh;
+ }
+ else if (fh->type == GNUNET_DISK_HANLDE_TYPE_FILE)
+ {
+ if (!except)
+ fds->handles[woff++] = fh;
+ }
+ else
+ {
+ if (WAIT_OBJECT_0 == WaitForSingleObject (fh, 0))
+ fds->handles[woff++] = fh;
+ }
}
fds->handles_pos = woff;
return woff;
@@ -1951,6 +1962,11 @@
for (i = 0; i <rfds->handles_pos; i++)
{
fh = rfds->handles[i];
+ if (fh->type == GNUNET_DISK_HANLDE_TYPE_EVENT)
+ {
+ handle_array[nhandles++] = fh->h;
+ continue;
+ }
if (fh->type != GNUNET_DISK_HANLDE_TYPE_PIPE)
continue;
/* Read zero bytes to check the status of the pipe */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34977 - in gnunet/src: include util,
gnunet <=