Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
514e97ea
Commit
514e97ea
authored
27 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/files/file.c
+8
-19
8 additions, 19 deletions
src/modules/files/file.c
with
8 additions
and
19 deletions
src/modules/files/file.c
+
8
−
19
View file @
514e97ea
...
...
@@ -6,7 +6,7 @@
#define READ_BUFFER 8192
#include
"global.h"
RCSID
(
"$Id: file.c,v 1.7
6
1998/0
2/20 01:08:58
hubbe Exp $"
);
RCSID
(
"$Id: file.c,v 1.7
7
1998/0
3/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
->
to
fd
,
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
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment