Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
b5316535
Commit
b5316535
authored
Mar 15, 2018
by
deuce
Browse files
Since we're supporting TLS now, use the sock.recv() timeout parameter instead
of poll()ing for each byte.
parent
60c5adda
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
65 deletions
+11
-65
exec/load/binkp.js
exec/load/binkp.js
+11
-65
No files found.
exec/load/binkp.js
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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment