mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Fix error in probe
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4731 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5f75cd4abd
commit
be2e9d5b5c
2 changed files with 55 additions and 65 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Aug 21 6:26:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Tools/gdomap.c: Fix for probing for other gdomap processes on the
|
||||||
|
net.
|
||||||
|
|
||||||
Fri Aug 20 16:17:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Fri Aug 20 16:17:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* NSNotificationQueue.m: notifyIdle() fix to send ASAP notifications
|
* NSNotificationQueue.m: notifyIdle() fix to send ASAP notifications
|
||||||
|
|
115
Tools/gdomap.c
115
Tools/gdomap.c
|
@ -97,7 +97,7 @@ typedef unsigned char *uptr;
|
||||||
int debug = 0; /* Extra debug logging. */
|
int debug = 0; /* Extra debug logging. */
|
||||||
int nofork = 0; /* turn off fork() for debugging. */
|
int nofork = 0; /* turn off fork() for debugging. */
|
||||||
int noprobe = 0; /* turn off probe for unknown servers. */
|
int noprobe = 0; /* turn off probe for unknown servers. */
|
||||||
int interval = 300; /* Minimum time (sec) between probes. */
|
int interval = 600; /* Minimum time (sec) between probes. */
|
||||||
|
|
||||||
int udp_sent = 0;
|
int udp_sent = 0;
|
||||||
int tcp_sent = 0;
|
int tcp_sent = 0;
|
||||||
|
@ -509,17 +509,17 @@ typedef struct {
|
||||||
} prb_type;
|
} prb_type;
|
||||||
prb_type **prb = 0;
|
prb_type **prb = 0;
|
||||||
|
|
||||||
static prb_type *prb_get(struct in_addr *old);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name - prb_add()
|
* Name - prb_add()
|
||||||
* Purpose - Create a new probe entry in the list in the
|
* Purpose - Create a new probe entry in the list.
|
||||||
* appropriate position.
|
* The new entry is always placed at the end of the list
|
||||||
|
* so that the list remains in the order in which hosts
|
||||||
|
* have been contancted.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
prb_add(struct in_addr *p)
|
prb_add(struct in_addr *p)
|
||||||
{
|
{
|
||||||
prb_type *n;
|
prb_type *n = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (is_local_host(*p) != 0)
|
if (is_local_host(*p) != 0)
|
||||||
|
@ -531,16 +531,37 @@ prb_add(struct in_addr *p)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = prb_get(p);
|
/*
|
||||||
if (n)
|
* If we already have an entry for this address, remove it from the list
|
||||||
|
* ready for re-insertion in the correct place.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < prb_used; i++)
|
||||||
{
|
{
|
||||||
n->when = time(0);
|
if (memcmp(&prb[i]->sin, p, IASIZE) == 0)
|
||||||
return;
|
{
|
||||||
|
n = prb[i];
|
||||||
|
for (i++; i < prb_used; i++)
|
||||||
|
{
|
||||||
|
prb[i-1] = prb[i];
|
||||||
|
}
|
||||||
|
prb_used--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a new entry structure if necessary.
|
||||||
|
* Set the current time in the structure, so we know when we last had contact.
|
||||||
|
*/
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
n = (prb_type*)malloc(sizeof(prb_type));
|
||||||
|
n->sin = *p;
|
||||||
}
|
}
|
||||||
n = (prb_type*)malloc(sizeof(prb_type));
|
|
||||||
n->sin = *p;
|
|
||||||
n->when = time(0);
|
n->when = time(0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Grow the list if we need more space.
|
||||||
|
*/
|
||||||
if (prb_used >= prb_size)
|
if (prb_used >= prb_size)
|
||||||
{
|
{
|
||||||
int size = (prb_size + 16) * sizeof(prb_type*);
|
int size = (prb_size + 16) * sizeof(prb_type*);
|
||||||
|
@ -556,57 +577,14 @@ prb_add(struct in_addr *p)
|
||||||
prb_size = 16;
|
prb_size = 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < prb_used; i++)
|
|
||||||
{
|
|
||||||
if (memcmp((char*)&prb[i]->sin, (char*)&n->sin, IASIZE) > 0)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for (j = prb_used+1; j > i; j--)
|
/*
|
||||||
{
|
* Append the new item at the end of the list.
|
||||||
prb[j] = prb[j-1];
|
*/
|
||||||
}
|
prb[prb_used] = n;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prb[i] = n;
|
|
||||||
prb_used++;
|
prb_used++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Name - prb_get()
|
|
||||||
* Purpose - Search the list for an entry for a particular addr
|
|
||||||
*/
|
|
||||||
static prb_type*
|
|
||||||
prb_get(struct in_addr *p)
|
|
||||||
{
|
|
||||||
int lower = 0;
|
|
||||||
int upper = prb_used;
|
|
||||||
int index;
|
|
||||||
|
|
||||||
for (index = upper/2; upper != lower; index = lower + (upper - lower)/2)
|
|
||||||
{
|
|
||||||
int i = memcmp(&prb[index]->sin, p, IASIZE);
|
|
||||||
|
|
||||||
if (i < 0)
|
|
||||||
{
|
|
||||||
lower = index + 1;
|
|
||||||
}
|
|
||||||
else if (i > 0)
|
|
||||||
{
|
|
||||||
upper = index;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (index<prb_used && memcmp(&prb[index]->sin,p,IASIZE)==0)
|
|
||||||
{
|
|
||||||
return prb[index];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Name - prb_del()
|
* Name - prb_del()
|
||||||
|
@ -1972,15 +1950,24 @@ handle_request(int desc)
|
||||||
else if (type == GDO_SERVERS)
|
else if (type == GDO_SERVERS)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int j;
|
||||||
|
|
||||||
free(w_info[desc].buf);
|
free(w_info[desc].buf);
|
||||||
w_info[desc].buf = (char*)malloc(sizeof(unsigned long) +
|
w_info[desc].buf = (char*)malloc(sizeof(unsigned long) +
|
||||||
(prb_used+1)*IASIZE);
|
(prb_used+1)*IASIZE);
|
||||||
*(unsigned long*)w_info[desc].buf = htonl(prb_used+1);
|
*(unsigned long*)w_info[desc].buf = htonl(prb_used+1);
|
||||||
mcopy(&w_info[desc].buf[4], &r_info[desc].addr.sin_addr, IASIZE);
|
mcopy(&w_info[desc].buf[4], &r_info[desc].addr.sin_addr, IASIZE);
|
||||||
for (i = 0; i < prb_used; i++)
|
|
||||||
|
/*
|
||||||
|
* Copy the addresses of the hosts we have probed into the buffer.
|
||||||
|
* During the copy, reverse the order of the addresses so that the
|
||||||
|
* address we have contacted most recently is first. This should
|
||||||
|
* ensure that the client process will attempt to contact live
|
||||||
|
* hosts before dead ones.
|
||||||
|
*/
|
||||||
|
for (i = 0, j = prb_used; i < prb_used; i++)
|
||||||
{
|
{
|
||||||
mcopy(&w_info[desc].buf[4+(i+1)*IASIZE], &prb[i]->sin, IASIZE);
|
mcopy(&w_info[desc].buf[4+(i+1)*IASIZE], &prb[--j]->sin, IASIZE);
|
||||||
}
|
}
|
||||||
w_info[desc].len = 4 + (prb_used+1)*IASIZE;
|
w_info[desc].len = 4 + (prb_used+1)*IASIZE;
|
||||||
}
|
}
|
||||||
|
@ -2197,9 +2184,7 @@ handle_send()
|
||||||
fprintf(stderr, "failed sendto for %s\n",
|
fprintf(stderr, "failed sendto for %s\n",
|
||||||
inet_ntoa(entry->addr.sin_addr));
|
inet_ntoa(entry->addr.sin_addr));
|
||||||
}
|
}
|
||||||
u_queue = entry->next;
|
queue_pop();
|
||||||
free(entry->dat);
|
|
||||||
free(entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2903,7 +2888,7 @@ main(int argc, char** argv)
|
||||||
printf("-c file use config file for probe.\n");
|
printf("-c file use config file for probe.\n");
|
||||||
printf("-d extra debug logging.\n");
|
printf("-d extra debug logging.\n");
|
||||||
printf("-f avoid fork() to make debugging easy\n");
|
printf("-f avoid fork() to make debugging easy\n");
|
||||||
printf("-i seconds re-probe at this interval (roughly)\n");
|
printf("-i seconds re-probe at this interval (roughly), min 60\n");
|
||||||
printf("-p obsolete no-op\n");
|
printf("-p obsolete no-op\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue