-
Notifications
You must be signed in to change notification settings - Fork 75
wait for entire buffer to be written before returning when calling sftp_write #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ dist | |
build | ||
*~ | ||
*.so | ||
.idea/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,7 +270,12 @@ cdef class SFTPHandle: | |
cdef char *cbuf = buf | ||
cdef ssize_t rc | ||
with nogil: | ||
rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) | ||
while _size > 0: | ||
rc = c_sftp.libssh2_sftp_write(self._handle, cbuf, _size) | ||
if rc < 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you elaborate on this? why not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mistake actually :) |
||
break | ||
cbuf += rc | ||
_size -= rc | ||
return handle_error_codes(rc) | ||
|
||
IF EMBEDDED_LIB: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change if
_size
is 0rc
will be undefined and will cause a crash. Can skip call to write and just return 0 in that case.