Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
8d9e8f70
Commit
8d9e8f70
authored
May 20, 2015
by
Vadim Troshchinskiy
Committed by
Mike Gabriel
Sep 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix negotiation in stage 10 error
Problem fixed by adding a select() call to implement a timeout, and retrying writes if needed.
parent
1fe33b71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
1 deletion
+37
-1
Loop.cpp
nxcomp/Loop.cpp
+37
-1
No files found.
nxcomp/Loop.cpp
View file @
8d9e8f70
...
@@ -8100,16 +8100,52 @@ int ReadRemoteData(int fd, char *buffer, int size, char stop)
...
@@ -8100,16 +8100,52 @@ int ReadRemoteData(int fd, char *buffer, int size, char stop)
int
WriteLocalData
(
int
fd
,
const
char
*
buffer
,
int
size
)
int
WriteLocalData
(
int
fd
,
const
char
*
buffer
,
int
size
)
{
{
int
position
=
0
;
int
position
=
0
;
int
ret
=
0
;
fd_set
writeSet
;
struct
timeval
selectTs
=
{
30
,
0
};
while
(
position
<
size
)
while
(
position
<
size
)
{
{
// A write to a non-blocking socket may fail with EAGAIN. The problem is
// that cache data is done in several writes, and there's no easy way
// to handle failure without rewriting a significant amount of code.
//
// Bailing out of the outer loop would result in restarting the sending
// of the entire cache list, which would confuse the other side.
FD_ZERO
(
&
writeSet
);
FD_SET
(
fd
,
&
writeSet
);
ret
=
select
(
fd
+
1
,
NULL
,
&
writeSet
,
NULL
,
&
selectTs
);
#ifdef DEBUG
*
logofs
<<
"Loop: WriteLocalData: select() returned with a code of "
<<
ret
<<
" and remaining timeout of "
<<
selectTs
.
tv_sec
<<
" sec, "
<<
selectTs
.
tv_usec
<<
"usec
\n
"
<<
logofs_flush
;
#endif
if
(
ret
<
0
)
{
*
logofs
<<
"Loop: Error in select() when writing data to FD#"
<<
fd
<<
": "
<<
strerror
(
EGET
())
<<
"
\n
"
<<
logofs_flush
;
if
(
EGET
()
==
EINTR
)
continue
;
return
-
1
;
}
else
if
(
ret
==
0
)
{
*
logofs
<<
"Loop: Timeout expired in select() when writing data to FD#"
<<
fd
<<
": "
<<
strerror
(
EGET
())
<<
"
\n
"
<<
logofs_flush
;
return
-
1
;
}
int
result
=
write
(
fd
,
buffer
+
position
,
size
-
position
);
int
result
=
write
(
fd
,
buffer
+
position
,
size
-
position
);
getNewTimestamp
();
getNewTimestamp
();
if
(
result
<=
0
)
if
(
result
<=
0
)
{
{
if
(
result
<
0
&&
EGET
()
==
EINTR
)
if
(
result
<
0
&&
(
EGET
()
==
EINTR
||
EGET
()
==
EAGAIN
||
EGET
()
==
EWOULDBLOCK
)
)
{
{
continue
;
continue
;
}
}
...
...
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