Commit Graph

93 Commits

Author SHA1 Message Date
Dave Cheney f2782dd6fa Move Request.handle to *Request
Updates #192

Move handle() onto *Request, this has flow on effects to the interface
types declared in request-interface.go, the examples and the tests.

The decision to address #192 started with advice from gopl.io, but I
think has uncovered several bugs as many of the request methods operate
on copies of data stored in the RequestServer's cache. I think this is
unintentional, but may point to some correctness issues, see #193.
2017-08-13 17:22:00 +10:00
John Eikenberry 1a91f318a0 make (sS)ftpServerWorkerCount constant public
The number of workers is important for some functionality in
request-server extentions. It is a constant, so making it public
seems easy and safe.
2017-08-10 17:53:41 -07:00
John Eikenberry 733115c415 Fixes #184; better fix for file batching
I didn't like how the initial fix for #184 required the handler author
to track the token/offset for the filelist. I came up with a way to do
it that mimic'd the FileReader handler interface using a method
something like ReaderAt except for file lists.

changed MaxFileinfoList to a var for testing and tweaking

Renaming FileInfoer interface to FileLister.
FileInfoer -> FileLister
Fileinfo -> Filelist
2017-08-10 15:36:41 -07:00
Andreas 505f2cb49e Fixed issues with backslashes on windows systems 2017-08-09 17:25:44 +02:00
John Eikenberry d02a2715ba Fixes #184; request server file list batching
The request server needs to support batching of file list requests. To
address this the methods LsSave(string) and LsNext()string are added to
the Request object. They should work to store a token to keep your place.

The Handler should now return an EOF when the end of the directory list is
reached. If it doesn't but returns an empty list, the wrapper will send the EOF
for you.

The old behaviour of just returning 1 batch and sending the EOF is preserved if
you don't set the token (you don't use LsSave). It will return the 1 list and
EOF on the next underlying readdir call. This is to preserve backwards
compatibility and it not the recommended way to handle file lists.
2017-07-10 16:43:58 -07:00
John Eikenberry 2482bdeeb8 remove unused packet cases from request.update
fstat and fsetstat are not converted to versions that work on path
instead of working with open filehandle. So I removed them from the
request.update method which updates the request object for methods that
are working on an opened file.
2017-04-24 22:28:26 -07:00
John Eikenberry 032a928990 Propagate Flags from setstat packet to request
Had file attributes, but not the flags which are required for the
attributes to be meaningful. The stats stuff in the request-server is
very simplistic, but I want it to be able to be used even if a PITA.
2017-04-24 21:51:06 -07:00
John Eikenberry a3c585f638 Fix several Setstat typos in request-server
Added a test that breaks w/ old code which has typos but is fixed with
typos fixed. Also added switch-default error message that would have
helped diagnose this (should have been there already).
2017-04-24 21:36:09 -07:00
Artyom Pervukhin f581f81666 Pass actual errors from FileReader/FileWriter implementations
Fixes #163
2017-03-25 16:48:13 -07:00
John Eikenberry a4eb07c029 NewRequest() now takes method as first param 2017-02-18 18:20:37 -08:00
John Eikenberry 044c5f4c92 make linter happy with NewRequest comment 2017-02-18 18:20:37 -08:00
John Eikenberry df02b6e10d make NewRequest public 2017-02-18 18:20:37 -08:00
John Eikenberry 7e76fd5451 close reader/writer when deleting request 2017-02-18 18:20:37 -08:00
John Eikenberry 016dabfa49 golint and go vet fixes 2017-02-18 18:20:37 -08:00
John Eikenberry 117dcd5916 refactor request setup into init and update
More understandable and adds additional type safety.
2017-02-18 18:20:37 -08:00
John Eikenberry ce4586e8a5 convert request to be pass by value
Encapsulate stateful data into sub-structures with pointer references
from the Request structure. This allows me to pass by value in most
cases to keep non-stateful (write once) data data race free and tightly
controlling access to stateful data to ease locking.
2017-02-18 18:20:37 -08:00
John Eikenberry 94ae9c6822 fix issue with out-of-order packets 2017-02-18 18:20:37 -08:00
John Eikenberry f18f3a1b48 govet fixes 2017-02-18 18:20:37 -08:00
John Eikenberry bf94760e22 golinter suggested name fix 2017-02-18 18:20:37 -08:00
John Eikenberry 9962211713 linter fixes 2017-02-18 18:20:37 -08:00
John Eikenberry 96da577ac9 remove superfluous pflags field from request
Pflags specify file open operations which don't make sense for the
request based interface and they were never used.
2017-02-18 18:20:37 -08:00
John Eikenberry 34d67613fb fix readlink name reference 2017-02-18 18:20:37 -08:00
John Eikenberry 3f4950f1d7 clean all incoming path data 2017-02-18 18:20:36 -08:00
John Eikenberry e8d7a278de move realpath handling into request-server 2017-02-18 18:20:36 -08:00
John Eikenberry e3e8165290 save EOF state of readdir 2017-02-18 18:20:36 -08:00
John Eikenberry 15c875477a add remove and realpath handling 2017-02-18 18:20:36 -08:00
John Eikenberry dab4d2c9cb forgot Remove command 2017-02-18 18:20:36 -08:00
John Eikenberry f6042b29bc remove redundant 'request' from handle method name 2017-02-18 18:20:36 -08:00
John Eikenberry e307459f45 factor out response struct 2017-02-18 18:20:36 -08:00
John Eikenberry 14982642a1 couple fixed found while writing tests 2017-02-18 18:20:36 -08:00
John Eikenberry 42095a108c move request.populate call out of handler
makes handler testing much simpler as it only needs a populated request
instead of faked packets.
2017-02-18 18:20:36 -08:00
John Eikenberry 2bf0b275fe added a few comments 2017-02-18 18:20:36 -08:00
John Eikenberry f3ebdef6de factor out request channels 2017-02-18 18:20:36 -08:00
John Eikenberry a253a470f0 move open handling to packet level 2017-02-18 18:20:36 -08:00
John Eikenberry cdfae2dc1d pass/store handlers on request vs server 2017-02-18 18:20:36 -08:00
John Eikenberry 595444c745 more work on decoupling packet/request handling 2017-02-18 18:20:36 -08:00
John Eikenberry fd475710b5 add response channel from req to packet handler
working to decouple request handling from packet handling. adding a
response channel means I don't need to handle sending packets.

eliminated need for cur_pkt and sendError() on request objects so far.
2017-02-18 18:20:36 -08:00
John Eikenberry ad74a75b7a pass packets to handler wrapper
vs. using one saved on struct (trying to get rid of this one)
2017-02-18 18:20:36 -08:00
John Eikenberry 1876432871 Add explicit Open noop 2017-02-18 18:20:36 -08:00
John Eikenberry 39fd50db3d better interface naming consistency 2017-02-18 18:20:36 -08:00
John Eikenberry 39e544ecfe make RequestServer.Handlers public 2017-02-18 18:20:36 -08:00
John Eikenberry e19ab67571 fleshed out processing handlers 2017-02-18 18:20:36 -08:00
John Eikenberry 06bf237860 reworked in branch and liked it 2017-02-18 18:20:36 -08:00