Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Main
Synchronet
Commits
b5316535
Commit
b5316535
authored
7 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Since we're supporting TLS now, use the sock.recv() timeout parameter instead
of poll()ing for each byte.
parent
60c5adda
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/binkp.js
+11
-65
11 additions, 65 deletions
exec/load/binkp.js
with
11 additions
and
65 deletions
exec/load/binkp.js
+
11
−
65
View file @
b5316535
...
...
@@ -948,50 +948,16 @@ BinkP.prototype.recvFrame = function(timeout)
if
(
this
.
partialFrame
===
undefined
)
{
ret
=
new
this
.
Frame
();
switch
(
this
.
sock
.
poll
(
timeout
))
{
case
0
:
// Timeout
if
(
timeout
)
{
log
(
LOG_WARNING
,
"
Timed out receiving packet header!
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
}
return
null
;
default
:
log
(
LOG_ERROR
,
"
Error select()ing socket.
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
case
1
:
break
;
}
buf
=
this
.
sock
.
recv
(
1
);
buf
=
this
.
sock
.
recv
(
1
,
timeout
);
if
(
buf
===
null
||
buf
.
length
!==
1
)
{
log
(
LOG_INFO
,
"
Remote
disconnect
ed
"
);
log
(
LOG_INFO
,
"
Error in recv() timeout or
disconnect
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
}
switch
(
this
.
sock
.
poll
(
timeout
))
{
case
0
:
// Timeout
if
(
timeout
)
{
log
(
LOG_WARNING
,
"
Timed out receiving second byte of packet header!
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
}
return
null
;
default
:
log
(
LOG_ERROR
,
"
Error select()ing socket.
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
case
1
:
break
;
}
buf
+=
this
.
sock
.
recv
(
1
);
buf
+=
this
.
sock
.
recv
(
1
,
timeout
);
if
(
buf
.
length
!==
2
)
{
log
(
LOG_ERROR
,
"
Remote disconnected before sending second byte of packet header!
"
);
log
(
LOG_ERROR
,
"
Remote disconnected
or timed out
before sending second byte of packet header!
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
...
...
@@ -1005,34 +971,14 @@ BinkP.prototype.recvFrame = function(timeout)
else
ret
=
this
.
partialFrame
;
switch
(
this
.
sock
.
poll
(
timeout
))
{
case
1
:
avail
=
this
.
sock
.
nread
;
if
(
avail
==
0
)
{
if
(
this
.
sock
.
is_connected
)
log
(
LOG_ERROR
,
"
Poll returned data available, but no data available on connected socket!
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
}
if
(
avail
>
(
ret
.
length
-
ret
.
data
.
length
))
avail
=
ret
.
length
-
ret
.
data
.
length
;
ret
.
data
+=
this
.
recv_buf
(
this
.
sock
.
recv
(
avail
));
break
;
case
0
:
if
(
timeout
)
{
log
(
LOG_ERROR
,
"
Timed out receiving packet data!
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
}
break
;
default
:
log
(
LOG_ERROR
,
"
Error select()ing socket.
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
i
=
this
.
recv_buf
(
this
.
sock
.
recv
(
ret
.
length
-
ret
.
data
.
length
));
if
(
i
==
null
||
i
.
length
==
0
)
{
log
(
LOG_ERROR
,
"
Remote disconnected or timed out while receiving packet data!
"
);
this
.
sock
.
close
();
this
.
sock
=
undefined
;
return
undefined
;
}
ret
.
data
+=
i
;
if
(
ret
.
data
.
length
<
ret
.
length
)
this
.
partialFrame
=
ret
;
...
...
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