1
1

62 Коммитов

Автор SHA1 Сообщение Дата
Daniel Stenberg
588c8946fc decomp: remove the free_dest argument
Since the decompress function ALWAYS returns allocated memory we get a
lot simpler code by removing the ability to return data unallocated.
2010-11-03 15:03:57 +01:00
Daniel Stenberg
a6fc9aeec9 decomp: cleaned off old compression stuff
I cleared off legacy code from when the compression and decompression
functions were a single unified function. Makes the code easier to read
too.
2010-11-03 14:52:42 +01:00
Daniel Stenberg
753e55ef23 _libssh2_transport_send: remove dead assignment
'data' isn't accessed beyond this point so there's no need to assign it.
2010-11-01 23:00:07 +01:00
Daniel Stenberg
dec0ea9e70 send_existing: don't tell parent to return when drained
That will just cause unnecessary code execution.
2010-10-23 00:47:51 +02:00
Daniel Stenberg
c48840ba88 _libssh2_transport_send: replaces _libssh2_transport_write
The new function takes two data areas, combines them and sends them as a
single SSH packet. This allows several functions to allocate and copy
less data.

I also found and fixed a mixed up use of the compression function
arguments that I introduced in my rewrite in a recent commit.
2010-10-23 00:11:59 +02:00
Daniel Stenberg
c49061e708 send_existing: clear olen when the data is sent off 2010-10-22 13:37:14 +02:00
Daniel Stenberg
d674b1a09a _libssh2_transport_write: allow 256 extra bytes around the packet 2010-10-22 13:37:13 +02:00
Daniel Stenberg
5ede32a826 _libssh2_transport_write: remade to send without malloc 2010-10-22 13:37:13 +02:00
Daniel Stenberg
59636cc11e compress: faster check, better return codes
In the transport functions we avoid a strcmp() now and just check a
boolean instead.

The compress/decompress function's return code is now acknowledged and
used as actual return code in case of failures.
2010-10-08 16:26:50 +02:00
Daniel Stenberg
861fc75fa3 _libssh2_transport_drain: removed
This function proved not to be used nor useful.
2010-10-07 13:30:05 +02:00
Daniel Stenberg
4faf67d3e9 _libssh2_transport_write: updated documentation blurb 2010-10-07 13:17:28 +02:00
Daniel Stenberg
76a30f2c6f _libssh2_transport_write: remove fprintf remainder
Mistake from previous debugging
2010-10-07 12:57:08 +02:00
Daniel Stenberg
7c49c8be58 transport: better error codes
LIBSSH2_SOCKET_NONE (-1) should no longer be used as error code as it is
(too) generic and we should instead use specific and dedicated error
codes to better describe the error.
2010-10-07 11:18:14 +02:00
Daniel Stenberg
71fb9cc93e cleanup: prefer the internal functions
To get the blocking vs non-blocking to work as smooth as possible
and behave better internally, we avoid using the external
interfaces when calling functions internally.

Renamed a few internal functions to use _libssh2 prefix when not
being private within a file, and removed the libssh2_ for one
that was private within the file.
2010-04-25 19:35:43 +02:00
Daniel Stenberg
1acca6e3ee remove check for negative padding_length
It was silly, since it is read as an unsigned char...
2010-04-20 22:48:40 +02:00
Daniel Stenberg
100059989f data types: convert more to use size_t and uint32_t 2010-04-17 13:34:44 +02:00
Daniel Stenberg
c3bcdd88a4 cleanups: better binary packet gen, size_t fixes and PACKET_* removal
I'll introduce a new internal function set named

 _libssh2_store_u32
 _libssh2_store_u64
 _libssh2_store_str

That can be used all through the library to build binary outgoing
packets.  Using these instead of the current approach removes
hundreds of lines from the library while at the same time greatly
enhances readability. I've not yet fully converted everything to
use these functions.

I've converted LOTS of 'unsigned long' to 'size_t' where
data/string lengths are dealt with internally. This is The Right
Thing and it will help us make the transition to our
size_t-polished API later on as well.

I'm removing the PACKET_* error codes. They were originally
introduced as a set of separate error codes from the transport
layer, but having its own set of errors turned out to be very
awkward and they were then converted into a set of #defines that
simply maps them to the global libssh2 error codes instead. Now,
I'l take the next logical step and simply replace the PACKET_*
defines with the actual LIBSSH2_ERROR_* defines. It will increase
readability and decrease confusion.

I also separated packet stuff into its own packet.h header file.
2010-04-17 13:18:15 +02:00
Daniel Stenberg
1adcb5234f rename libssh2_error to the correct _libssh2_error
We reserve ^libssh2_ for public symbols and we use _libssh2 as
prefix for internal ones. I fixed the intendation of all these
edits with emacs afterwards, which then changed it slightly more
than just _libssh2_error() expressions but I didn't see any
obvious problems.
2010-04-16 00:18:51 +02:00
Daniel Stenberg
7f740368f4 channel/transport: we now drain the outgoing send buffer when we ignore EAGAIN
When we ignore the EAGAIN from the transport layer within channel_write, we
now drain the outgoing transport layer buffer so that remainders in that
won't cause any problems in the next invoke of _libssh2_transport_write()
2010-04-15 01:12:22 +02:00
Peter Stuge
b6ed60d2cc Correctly clear blocking flag after sending multipart packet
commit 7317edab61d2179febc38a2c2c4da0b951d74cbc cleared the outbound
blocking bit when send_existing() returned PACKET_NONE and *ret=0, as
opposed to before even calling send_existing(), but because *ret=1 when
sending parts 2..n of an existing packet, the bit would only be cleared
when calling libssh2_transport_write() for a new packet.

Clear the direction flag after the final part of a packet has been sent.
2010-03-28 01:35:55 +01:00
Daniel Stenberg
d4a768af4e removed libssh2_error()'s forth argument
libssh2_error() no longer allocates a string and only accepts a const
error string. I also made a lot of functions use the construct of
return libssh2_error(...) instead of having one call to
libssh2_error() and then a separate return call. In several of those
cases I then also changed the former -1 return code to a more
detailed one - something that I think will not change behaviors
anywhere but it's worth keeping an eye open for any such.
2010-03-03 23:04:05 +01:00
Sofian Brabez
a190437c4a Replace : in hexdump with " " (two spaces) 2010-02-01 16:30:47 +01:00
Dave McCaldon
f077984394 Pass user context through libssh2_trace_sethandler() to callback
The libssh2_trace_sethandler() call allows the user to handle the output of libssh2 rather than having it written to stderr.  This patch updates libssh2_trace_sethandler() to allow a user-defined void* context value to be passed back to the output handler.
2010-01-20 19:42:09 +01:00
Dave McCaldon
44eba0c993 Add libssh2_trace_sethandler() to the API (even more) 2010-01-15 22:58:44 +01:00
Peter Stuge
d142f385da Use LIBSSH2_TRACE_* internally and remove redundant LIBSSH2_DBG_* 2009-12-08 08:52:03 +01:00
Peter Stuge
1a491c6f00 Add LIBSSH2_TRACE_SOCKET context for tracing send() and recv()
Helpful in debugging the -39 errors.
2009-12-08 08:40:30 +01:00
Peter Stuge
1256c61815 Another transport layer fix for bogus -39 (LIBSSH2_ERROR_BAD_USE) errors
Commit 683aa0f6b52fb1014873c961709102b5006372fc made send_existing() send
more than just the second part of a packet when the kernel did not accept
the full packet, but the function still overlooked the SSH protocol
overhead in each packet, often 48 bytes.

If only the last few bytes of a packet remained, then the packet would
erroneously be considered completely sent, and the next call to write
more data in the session would return a -39 error.
2009-12-08 07:33:05 +01:00
Peter Stuge
7317edab61 Don't always clear write direction blocking flag
When libssh2_transport_write() is called to continue sending a
partially sent packet the write direction flag must not be cleared
until the previous packet has been completely sent, or the app would
hang if the packet still isn't sent completely, since select() gets
called by the internal blocking emulation layer in libssh2 but would
then not be watching the socket for writability.

Clear the flag only once processing of previous packet data is
complete and a new packet is about to be prepared.
2009-11-27 07:52:26 +01:00
Peter Stuge
683aa0f6b5 Fix transport layer bug causing invalid -39 (LIBSSH2_ERROR_BAD_USE) errors
The channel layer sends packets using the transport layer, possibly
calling _libssh2_transport_write() many times for each packet.

The transport layer uses the send_existing() helper to send out any
remaining parts of previous packets before a new packet is started.

The bug made send_existing() consider the entire packet sent as soon as it
successfully sent the second part of a packet, even if the packet was not
completely done yet.
2009-09-20 00:30:42 +02:00
Daniel Stenberg
face4750ca changed all return EAGAIN to return the variable instead
I made this change just to easier grep for "return .*EAGAIN" cases
as they should be very rare or done wrongly. Already worked to find
a flaw, marked with "TODO FIXME THIS IS WRONG" in channel.c. I also
fixed a few cases to become more general returns now when we have
more unified return codes internally.
2009-08-25 00:54:47 +02:00
Daniel Stenberg
fba3877ed8 remove all libssh2pack_t leftovers 2009-08-24 23:57:15 +02:00
Daniel Stenberg
f1e010f5d4 removed the libssh2pack_t type
and a minor _libssh2_transport_read() simplification
2009-08-24 23:50:53 +02:00
Daniel Stenberg
e39128df52 simplified fullpacket, clarified _libssh2_transport_write() comment 2009-08-24 23:13:14 +02:00
Daniel Stenberg
d8b6f3c7b8 move over lots of code to the _libssh2_list_* functions
and I fixed a few minor bugs at the same time
2009-08-20 00:56:54 +02:00
Daniel Stenberg
cccaa868f5 revert parts of the b95fe985af3c80a2babcaaaf7da69a15b1237c49 commit
Alexander Lamaison tracked down that my previous commit broke SFTP
reads in some aspects. The reversion now gets back to always recv()
until EAGAIN is returned so that the code no longer treats a short
read as an indication that it is "enough for now".

The bad commit in particular had another independent change included,
which is to clear the direction-bits first in the transport read
and write functions, but this reversion does not revert that change.
Clearing those bits first is a good thing.
2009-08-07 11:33:59 +02:00
Daniel Stenberg
dd38d0a929 bad debugdump() causes SIGSEGV, partial sends not done right
The anonymous bug report #2822910 pointed out that debugdump() was
stupidly called within the send_existing() function. At closer
inspection was the report not only right, but it also revealed
another problem to me: when the _libssh2_send() function returns
after sending only a part of the buffer, it would then misbehave.
This probably is very rare though, which must be the reason we
haven't seen a bigger problem with this.
2009-07-28 19:57:02 +02:00
Simon Josefsson
ba57d5ae3c Silcen compiler warnings. 2009-07-28 13:27:43 +02:00
Daniel Stenberg
6f4463e81f remove superfluous check for large packets
as we're already doing the correct check further down anyway there's no point
in doing the (wrong) check further up as well. Paul Veldkamp pointed this out.
2009-07-27 22:54:18 +02:00
Daniel Stenberg
acbdbb8914 Applied Francois Dupoux's extra checks for weird packet or padding length in
incoming packets. We really need to bail out this way on weird input.
bug report #2814613
2009-07-07 13:26:42 +02:00
Daniel Stenberg
8b1ec197b2 fix a warning for a comparison mixing signed and unsigned types 2009-05-28 22:54:37 +02:00
Daniel Stenberg
b95fe985af If recv() returns something less than the full buffer we know we're done for
now, so skip looping and doing another read that then simply will cause an
EAGAIN as it may trick the user into believing things that aren't true.
2009-05-20 14:30:05 +02:00
Daniel Stenberg
76dab196b1 Dump to stderr simply because the other tracing functions in misc.c already
use stderr and mixing output "channels" causes too much confusion for me!
2009-03-27 21:51:43 +00:00
Daniel Stenberg
eabe072496 * Renamed the functions in src/transport.c to be _libssh2_transport_ prefixed
and introduced a transport.h header.

* Fixed the blocking mode to only change behavior not the actual underlying
  socket mode so we now always work with non-blocking sockets. This also
  introduces a new rule of thumb in libssh2 code: we don't call the
  external function calls internally. We use the internal (non-blocking)
  ones!

* libssh2_channel_receive_window_adjust2 was added and
  libssh2_channel_receive_window_adjust is now deprecated

* Introduced "local" header files with prototypes etc for different parts
  instead of cramming everything into libssh2_priv.h. channel.h is the
  first.
2009-03-26 15:41:14 +00:00
Daniel Stenberg
468272d648 - (Mar 19 2009) Daniel Stenberg: based on a patch by "E L" we now use errno
properly after recv() and send() calls (that internally are now known as
  _libssh2_recv() and _libssh2_send()) so that the API and more works fine on
  windows too!
2009-03-19 12:45:59 +00:00
Daniel Stenberg
cc5e952fa0 A cleanup effort: libssh2_ prefixes only on external APIs. Use _libssh2_ prefix
for library-wide internal functions. Don't use any of those on static functions.
I also did some comments and whitespace changes.
2009-03-17 13:48:35 +00:00
Daniel Stenberg
a52f5d3b7e Cleanups, that do seem to have boosted SFTP download performance up to 300% in
some tests:

  * cut off "_ex" from several internal function names

  * corrected some log outputs

  * simplified libssh2_channel_read_ex() and made it much faster in the process

  * cut out {{{ and }}} comments that were incorrect anyway

  * fixed sftp_packet_ask() to return the correct packet by using memcmp() and
    not strncmp()

  * fixed mkdir()'s wait for packet to use the correct request_id - it
    semi-worked previously because strncmp() in sftp_packet_ask() made it
    match far too easily.

  * took away the polling functionality from sftp_packet_ask() since it wasn't
    used
2009-03-13 22:15:27 +00:00
Daniel Stenberg
079d20aca8 remove unused #ifndef, and two whitespace changes 2008-12-22 22:31:51 +00:00
Daniel Stenberg
160f89f42e - Vlad Grachov brought the new function called
libssh2_session_block_directions() which returns a bitmask for what
  directions the connection blocks. It is to be used applications that use
  non-blocking sockets and when a libssh2 function returns
  LIBSSH2_ERROR_EAGAIN this function can be used to figure out in which
  direction the socket would block and thus it can wait for the socket to
  again be ready for communication in that direction before it calls libssh2
  again.
2008-11-24 13:31:00 +00:00
Daniel Stenberg
99afc66665 Sean Peterson's key re-exchange fix. See his long explanation on:
http://daniel.haxx.se/projects/libssh2/mail/libssh2-devel-archive-2008-06/0002.shtml
2008-07-03 16:26:55 +00:00
Daniel Stenberg
030b670e2a Moved the check that the amount of data is larger than the blocksize to
only get done on the first block. Based on the bug report #1826989
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1826989&group_id=125852
2007-11-08 13:51:23 +00:00