[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27825 - msh/src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27825 - msh/src |
Date: |
Tue, 9 Jul 2013 14:36:36 +0200 |
Author: harsha
Date: 2013-07-09 14:36:35 +0200 (Tue, 09 Jul 2013)
New Revision: 27825
Modified:
msh/src/mshd.c
Log:
- fixes
Modified: msh/src/mshd.c
===================================================================
--- msh/src/mshd.c 2013-07-09 11:23:37 UTC (rev 27824)
+++ msh/src/mshd.c 2013-07-09 12:36:35 UTC (rev 27825)
@@ -296,7 +296,7 @@
MSH_break (0);
goto err_ret;
}
- LOG_DEBUG ("Received message of size %d from %d\n", rsize, source);
+ LOG_DEBUG ("%d: Received message of size %d from %d\n", rank, rsize,
source);
}
/* remove this later on and do something useful */
for (cnt = 0; cnt < rwidth; cnt++)
@@ -330,6 +330,7 @@
int cnt;
int ret;
int target;
+ unsigned int width;
msize = sizeof (struct MSH_MSG_VerifyAddress) + (nips * sizeof (uint32_t));
msg = MSH_malloc (msize);
@@ -338,15 +339,19 @@
msg->nips = htons (nips);
for (cnt = 0; cnt < nips; cnt++)
msg->ipaddrs[cnt] = (uint32_t) s_addrs[cnt]; /* IPs already in NB */
+ width = rwidth;
+ if ( (0 != ( (nproc - 1) % rwidth)) && (round == ( (nproc - 1) / rwidth)) )
+ width = (nproc - 1) % rwidth;
cpys = NULL;
- cpys = MSH_malloc (msize * rwidth);
- sreqs = MSH_malloc (rwidth);
- for (cnt=0; cnt < rwidth; cnt++)
+ cpys = MSH_malloc (msize * width);
+ sreqs = MSH_malloc (width);
+ for (cnt=0; cnt < width; cnt++)
{
(void) memcpy (&cpys[cnt], msg, msize);
target = (round * rwidth) + cnt + 1;
MSH_assert (target < nproc);
target = (rank + target) % nproc;
+ LOG_DEBUG ("%d: Sending message to %d\n", rank, target);
ret = MPI_Isend (&cpys[cnt], msize, MPI_BYTE, target,
MSH_MTYPE_VERIFY_ADDRESSES, MPI_COMM_WORLD, &sreqs[cnt]);
if (MPI_SUCCESS != ret)
@@ -354,7 +359,7 @@
}
free (msg);
msg = NULL;
- if (cnt != rwidth)
+ if (cnt != width)
{
for (cnt--; cnt >= 0; cnt--)
{
@@ -363,7 +368,7 @@
}
goto end;
}
- for (cnt=0; cnt < rwidth; cnt++)
+ for (cnt=0; cnt < width; cnt++)
{
MSH_break (MPI_SUCCESS == MPI_Wait (&sreqs[cnt], MPI_STATUS_IGNORE));
}
@@ -415,6 +420,7 @@
}
if (MSH_SYSERR == send_receive_addresses ())
goto clo_ret;
+ MSH_close (sock); /* FIXME: remove later */
atask = scheduler_add_socket (sock, EV_READ, &accept_task, &atask, NULL);
if (MPI_SUCCESS != MPI_Barrier (MPI_COMM_WORLD))
{
@@ -498,6 +504,8 @@
if (MSH_OK == verify_addresses ())
{
round++;
+ scheduler_remove (atask);
+ atask = NULL;
schedule_next_round ();
}
}
@@ -514,7 +522,7 @@
run (evutil_socket_t nosock, short flags, void *cls)
{
LOG_DEBUG ("Running main task\n");
- sigshut_tasks[0] = scheduler_add_signal (SIGTERM, &sig_shutdown,
+ sigshut_tasks[0] = scheduler_add_signal (SIGINT, &sig_shutdown,
&sigshut_tasks[0], NULL);
sigshut_tasks[1] = scheduler_add_signal (SIGTERM, &sig_shutdown,
&sigshut_tasks[1], NULL);
@@ -541,9 +549,9 @@
int
main (int argc, char **argv)
{
+ extern char *optarg;
int ret;
int c;
-
ret = 1;
rwidth = 1;
@@ -552,12 +560,22 @@
switch (c)
{
case 'w':
- if (1 != sscanf (optarg, "%u", rwidth))
+ if (NULL == optarg)
{
+ LOG_ERROR ("Argument is NULL\n");
+ return 1;
+ }
+ if (1 != sscanf (optarg, "%u", &rwidth))
+ {
LOG_ERROR ("-w option requires an unsinged number argument.\n");
print_help ();
return 1;
}
+ if (0 == rwidth)
+ {
+ LOG_ERROR ("Round width cannot be 0\n");
+ return 1;
+ }
break;
case 'h':
print_help ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27825 - msh/src,
gnunet <=