aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-07-15 15:30:22 +0000
committerChristian Grothoff <christian@grothoff.org>2012-07-15 15:30:22 +0000
commit1990358dc1dbd02ea570cf833d16bb9301dd4d77 (patch)
tree4328443713d2830c746858815387c4c2fdd53d0e
parent00a4e4d095cbe0b6f9885d172eaeb029b6e13200 (diff)
downloadgnunet-1990358dc1dbd02ea570cf833d16bb9301dd4d77.tar.gz
gnunet-1990358dc1dbd02ea570cf833d16bb9301dd4d77.zip
-cleanup
-rw-r--r--src/util/os_priority.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index 55826618b..979511d8e 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -1340,7 +1340,7 @@ start_process (int pipe_control,
1340 fail = 1; 1340 fail = 1;
1341 do 1341 do
1342 { 1342 {
1343 int wrote; 1343 ssize_t wrote;
1344 uint64_t size; 1344 uint64_t size;
1345 unsigned int count; 1345 unsigned int count;
1346 unsigned int i; 1346 unsigned int i;
@@ -1349,9 +1349,11 @@ start_process (int pipe_control,
1349 for (count = 0; lsocks && lsocks[count] != INVALID_SOCKET; count++); 1349 for (count = 0; lsocks && lsocks[count] != INVALID_SOCKET; count++);
1350 1350
1351 wrote = GNUNET_DISK_file_write (lsocks_write_fd, &count, sizeof (count)); 1351 wrote = GNUNET_DISK_file_write (lsocks_write_fd, &count, sizeof (count));
1352 if (wrote != sizeof (count)) 1352 if (sizeof (count) != wrote)
1353 { 1353 {
1354 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write %u count bytes to the child: %u\n", sizeof (count), GetLastError ()); 1354 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1355 "Failed to write %u count bytes to the child: %u\n",
1356 sizeof (count), GetLastError ());
1355 break; 1357 break;
1356 } 1358 }
1357 for (i = 0; lsocks && lsocks[i] != INVALID_SOCKET; i++) 1359 for (i = 0; lsocks && lsocks[i] != INVALID_SOCKET; i++)
@@ -1360,8 +1362,9 @@ start_process (int pipe_control,
1360 /* Get a socket duplication info */ 1362 /* Get a socket duplication info */
1361 if (SOCKET_ERROR == WSADuplicateSocketA (lsocks[i], gnunet_proc->pid, &pi)) 1363 if (SOCKET_ERROR == WSADuplicateSocketA (lsocks[i], gnunet_proc->pid, &pi))
1362 { 1364 {
1363 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to duplicate an socket[%llu]: %u\n", i, GetLastError ()); 1365 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1364 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "CreateProcess"); 1366 "Failed to duplicate an socket[%llu]: %u\n", i,
1367 GetLastError ());
1365 break; 1368 break;
1366 } 1369 }
1367 /* Synchronous I/O is not nice, but we can't schedule this: 1370 /* Synchronous I/O is not nice, but we can't schedule this:
@@ -1374,16 +1377,20 @@ start_process (int pipe_control,
1374 */ 1377 */
1375 size = sizeof (pi); 1378 size = sizeof (pi);
1376 wrote = GNUNET_DISK_file_write (lsocks_write_fd, &size, sizeof (size)); 1379 wrote = GNUNET_DISK_file_write (lsocks_write_fd, &size, sizeof (size));
1377 if (wrote != sizeof (size)) 1380 if (sizeof (size) != wrote)
1378 { 1381 {
1379 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write %u size[%llu] bytes to the child: %u\n", sizeof (size), i, GetLastError ()); 1382 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1383 "Failed to write %u size[%llu] bytes to the child: %u\n",
1384 sizeof (size), i, GetLastError ());
1380 break; 1385 break;
1381 } 1386 }
1382 /* Finally! Send the data */ 1387 /* Finally! Send the data */
1383 wrote = GNUNET_DISK_file_write (lsocks_write_fd, &pi, sizeof (pi)); 1388 wrote = GNUNET_DISK_file_write (lsocks_write_fd, &pi, sizeof (pi));
1384 if (wrote != sizeof (pi)) 1389 if (sizeof (pi) != wrote)
1385 { 1390 {
1386 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write %u socket[%llu] bytes to the child: %u\n", sizeof (pi), i, GetLastError ()); 1391 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1392 "Failed to write %u socket[%llu] bytes to the child: %u\n",
1393 sizeof (pi), i, GetLastError ());
1387 break; 1394 break;
1388 } 1395 }
1389 } 1396 }
@@ -1502,9 +1509,7 @@ GNUNET_OS_start_process_va (int pipe_control,
1502 * @param pipe_stdout pipe to use to get output from child process (or NULL) 1509 * @param pipe_stdout pipe to use to get output from child process (or NULL)
1503 * @param filename name of the binary 1510 * @param filename name of the binary
1504 * @param ... NULL-terminated list of arguments to the process 1511 * @param ... NULL-terminated list of arguments to the process
1505 *
1506 * @return pointer to process structure of the new process, NULL on error 1512 * @return pointer to process structure of the new process, NULL on error
1507 *
1508 */ 1513 */
1509struct GNUNET_OS_Process * 1514struct GNUNET_OS_Process *
1510GNUNET_OS_start_process (int pipe_control, 1515GNUNET_OS_start_process (int pipe_control,
@@ -1654,6 +1659,7 @@ GNUNET_OS_process_status (struct GNUNET_OS_Process *proc,
1654 1659
1655/** 1660/**
1656 * Wait for a process 1661 * Wait for a process
1662 *
1657 * @param proc pointer to process structure 1663 * @param proc pointer to process structure
1658 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 1664 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
1659 */ 1665 */
@@ -1758,8 +1764,7 @@ struct GNUNET_OS_CommandHandle
1758void 1764void
1759GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd) 1765GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd)
1760{ 1766{
1761 1767 if (NULL != cmd->proc)
1762 if (cmd->proc != NULL)
1763 { 1768 {
1764 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != cmd->rtask); 1769 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != cmd->rtask);
1765 GNUNET_SCHEDULER_cancel (cmd->rtask); 1770 GNUNET_SCHEDULER_cancel (cmd->rtask);
@@ -1812,7 +1817,7 @@ cmd_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1812 } 1817 }
1813 end = memchr (&cmd->buf[cmd->off], '\n', ret); 1818 end = memchr (&cmd->buf[cmd->off], '\n', ret);
1814 cmd->off += ret; 1819 cmd->off += ret;
1815 while (end != NULL) 1820 while (NULL != end)
1816 { 1821 {
1817 *end = '\0'; 1822 *end = '\0';
1818 cmd->proc (cmd->proc_cls, cmd->buf); 1823 cmd->proc (cmd->proc_cls, cmd->buf);
@@ -1872,6 +1877,4 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, void *proc_cls,
1872} 1877}
1873 1878
1874 1879
1875
1876
1877/* end of os_priority.c */ 1880/* end of os_priority.c */