Skip to content
Snippets Groups Projects
Commit 0df56b24 authored by Per Hedbor's avatar Per Hedbor
Browse files

Fixes to spider.shuffle...

Rev: src/modules/spider/spider.c:1.54
parent 2043bab9
Branches
Tags
No related merge requests found
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "fdlib.h"
#include "stralloc.h" #include "stralloc.h"
#include "global.h" #include "global.h"
#include "pike_macros.h" #include "pike_macros.h"
...@@ -42,7 +43,7 @@ ...@@ -42,7 +43,7 @@
#include "threads.h" #include "threads.h"
#include "operators.h" #include "operators.h"
RCSID("$Id: spider.c,v 1.53 1998/02/10 15:44:57 per Exp $"); RCSID("$Id: spider.c,v 1.54 1998/02/11 00:27:01 per Exp $");
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
#include <pwd.h> #include <pwd.h>
...@@ -1300,13 +1301,13 @@ void *do_shuffle(void *_a) ...@@ -1300,13 +1301,13 @@ void *do_shuffle(void *_a)
while(!fail && a->len) while(!fail && a->len)
{ {
int nread, ts=0; int nread, ts=0;
nread = read(a->from_fd, buffer, 8192); nread = fd_read(a->from_fd, buffer, 8192);
if(nread <= 0) if(nread <= 0)
break; break;
while(nread) while(nread)
{ {
int nsent = write(a->to_fd, buffer, nread); int nsent = fd_write(a->to_fd, buffer, nread);
if(nsent < 0) if(nsent < 0)
{ {
fail=1; fail=1;
...@@ -1326,6 +1327,7 @@ void *do_shuffle(void *_a) ...@@ -1326,6 +1327,7 @@ void *do_shuffle(void *_a)
a->next = done; a->next = done;
done = a; done = a;
mt_unlock(&done_lock); mt_unlock(&done_lock);
wake_up_backend();
return 0; return 0;
} }
...@@ -1354,11 +1356,8 @@ void finished_p(struct callback *foo, void *b, void *c) ...@@ -1354,11 +1356,8 @@ void finished_p(struct callback *foo, void *b, void *c)
free(d); free(d);
} }
if(num_shuffles) if(!num_shuffles)
{ {
next_timeout = current_time;
next_timeout.tv_usec += 40000;
} else {
remove_callback( foo ); remove_callback( foo );
my_callback = 0; my_callback = 0;
} }
...@@ -1379,20 +1378,13 @@ void f_shuffle(INT32 args) ...@@ -1379,20 +1378,13 @@ void f_shuffle(INT32 args)
a->from->refs++; a->from->refs++;
a->to->refs++; a->to->refs++;
a->cb = *q; assign_svalue_no_free(&a->cb, q);
a->args = *w; assign_svalue_no_free(&a->args, w);
if(a->cb.type <= MAX_REF_TYPE) a->cb.u.refs[0]++;
if(a->args.type <= MAX_REF_TYPE) a->args.u.refs[0]++;
th_create_small(&a->tid, do_shuffle, (void *)a); th_create_small(&a->tid, do_shuffle, (void *)a);
if(!my_callback) if(!my_callback)
{
/* next_timeout = current_time; */
/* next_timeout.tv_usec += 40000; */
my_callback = add_backend_callback( finished_p, 0, 0 ); my_callback = add_backend_callback( finished_p, 0, 0 );
wake_up_backend();
}
pop_n_elems(args+2); pop_n_elems(args+2);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment