Skip to content
Snippets Groups Projects
Commit 514e97ea authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

Stdio.File->proxy() fixed

Rev: src/modules/files/file.c:1.77
parent 26f5e11f
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@
#define READ_BUFFER 8192
#include "global.h"
RCSID("$Id: file.c,v 1.76 1998/02/20 01:08:58 hubbe Exp $");
RCSID("$Id: file.c,v 1.77 1998/03/02 11:20:07 hubbe Exp $");
#include "fdlib.h"
#include "interpret.h"
#include "svalue.h"
......@@ -1617,9 +1617,7 @@ static void file_create(INT32 args)
struct new_thread_data
{
struct object *from;
struct object *to;
INT32 fromfd, tofd;
INT32 from, to;
};
static void *proxy_thread(void * data)
......@@ -1627,13 +1625,10 @@ static void *proxy_thread(void * data)
char buffer[READ_BUFFER];
struct new_thread_data *p=(struct new_thread_data *)data;
/* fprintf(stderr,"new proxy thread, from %d to %d.\n",p->fromfd,p->tofd); */
/* fprintf(stderr,"Thread started %p.\n",p); */
while(1)
{
long len, w;
/* fprintf(stderr,"reading from %d.\n",p->fromfd); */
len=fd_read(p->fromfd, buffer, READ_BUFFER);
len=fd_read(p->from, buffer, READ_BUFFER);
if(len==0) break;
if(len<0)
{
......@@ -1642,10 +1637,9 @@ static void *proxy_thread(void * data)
}
w=0;
/* fprintf(stderr,"writing to %d.\n",p->tofd); */
while(w<len)
{
long wl=fd_write(p->tofd, buffer+w, len-w);
long wl=fd_write(p->to, buffer+w, len-w);
if(wl<0)
{
if(errno==EINTR) continue;
......@@ -1655,10 +1649,9 @@ static void *proxy_thread(void * data)
}
}
/* fprintf(stderr,"Proxy thread (%d - %d) done.\n",p->fromfd,p->tofd); */
mt_lock(&interpreter_lock);
free_object(p->from);
free_object(p->to);
do_close(p->to, FILE_READ | FILE_WRITE);
do_close(p->from, FILE_READ | FILE_WRITE);
num_threads--;
mt_unlock(&interpreter_lock);
free((char *)p);
......@@ -1676,12 +1669,8 @@ void file_proxy(INT32 args)
error("Bad argument 1 to Stdio.File->proxy, not a Stdio.File object.\n");
p=ALLOC_STRUCT(new_thread_data);
p->to=fp->current_object;
p->tofd=FD;
p->from=sp[-args].u.object;
p->fromfd=f->fd;
p->to->refs++;
p->from->refs++;
files[p->from=f->fd].refs++;
files[p->to=FD].refs++;
num_threads++;
if(th_create_small(&id,proxy_thread,p))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment