Commit Graph

13 Commits

Author SHA1 Message Date
John Eikenberry 0cf318853f drop support for go versions <= 1.7 2018-01-25 17:44:22 -08:00
John Eikenberry bc6b56aae0 packageManager to use pointer receivers everywhere
Had a problem with getting a copy because a value receiver called a
pointer receiver.
2017-08-20 15:23:55 -07:00
andreas 4d7bb970c4 Resolved conflict with SftpServerWorkerCount
Splitted cleanPath into cleanPacketPath and cleanPath for better handling of slashes in file paths
Added test for cleanPath func
Removed code duplication => filepath.ToSlash(filepath.Clean(...)) => cleanPath(...)
Fixed tests for runLs to match year or time
Renamed constants to fit hound rules
2017-08-13 14:00:08 +02:00
John Eikenberry e97b9a47e1 avoid data race in worker creation
There is a data race with the waitgroup (wg) object used to synchronize
the workers with the server exit. The workers called wg.Add()
asynchronously and it was possible for the Wait() to get hit before any
of the Add() calls were made in certain conditions. I only ever saw this
sporatically in the travis tests.

This fixes it by making the wg.Add() calls synchronous.
2017-07-03 17:53:55 -07:00
John Eikenberry 63cbed8bae forgot to remove a tmp comment 2017-04-23 16:37:11 -07:00
John Eikenberry 5024cb048c Move packer ordering code into packet-manager
The worker/packet mangement code needs to be in the packet manager so
the request-server can utilize it as well. This also improves the
encapsulation of the method as it relied on internal data that should be
better isolated inside the file/struct.
2017-04-23 13:47:05 -07:00
John Eikenberry d1bd7b3f9c ensure packets are processed in order
File operations that happen after the open packet has been received,
like reading/writing, can be done with the pool as the order they are
run in doesn't matter (the packets contain the file offsets).

Command operations, on the other hand, need to be serialized.

This flips between a pool of workers for file operations and a single
worker for everything else. It flips on Open and Close packets.
2017-04-17 17:24:15 -07:00
Pavel Borzenkov df2f92e1bf packet-manager: sort incoming request ID queue
Incoming queue is not guaranteed to contain request IDs in ascending
order. Such state may be achieved by using a single sftp.Client
connection from multiple goroutines. Sort incoming queue to avoid
livelock due to different request/response order, like this:

2017/03/27 18:29:07 incoming: [55 56 54 57 58]
2017/03/27 18:29:07 outgoing: [54 55 56 57 58]

For single-threaded clients request/response order will remain intact
and nothing should break.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2017-04-05 14:15:57 -07:00
John Eikenberry c0171352dc Use sort.Slice() for go1.8+
I noticed a significan slowdown in throughput tested by the benchmarks
when using the pre go1.8 sort.Sort() method for sorting. So I decided to
split this out and use build flags so people could regain the
performance loss by upgrading to go1.8+.
2017-03-23 16:15:04 -07:00
John Eikenberry ebb5774945 improve top level comment 2017-03-23 16:15:04 -07:00
John Eikenberry c0a31022ae sorting incoming packet ids is redundant
Having this outside the worker pool means tcp will ensure packet
ordering is consistent with what the client sent.
2017-03-23 16:15:04 -07:00
John Eikenberry db7c5041e2 change sort.Slice() to sort.Sort() for 1.7 compat 2017-03-23 16:15:04 -07:00
John Eikenberry ded0784f45 code that manages incoming/outgoing packet order
Makes sure that outgoing packets order matches incoming packets order.
This is not required by spec but some clients seem to require it (eg.
winscp).
2017-03-23 16:15:04 -07:00