mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Convenience wrappers on plug_closing().
Having a single plug_closing() function covering various kinds of closure is reasonably convenient from the point of view of Plug implementations, but it's annoying for callers, who all have to fill in pointless NULL and 0 parameters in the cases where they're not used. Added some inline helper functions in network.h alongside the main plug_closing() dispatch wrappers, so that each kind of connection closure can present a separate API for the Socket side of the interface, without complicating the vtable for the Plug side. Also, added OS-specific extra helpers in the Unix and Windows directories, which centralise the job of taking an OS error code (of whatever kind) and translating it into its error message. In passing, this removes the horrible ad-hoc made-up error codes in proxy.h, which is OK, because nothing checked for them anyway, and also I'm about to do an API change to plug_closing proper that removes the need for them.
This commit is contained in:
@ -158,7 +158,7 @@ static void fdsocket_error_callback(void *vs)
|
||||
/*
|
||||
* An error has occurred on this socket. Pass it to the plug.
|
||||
*/
|
||||
plug_closing(fds->plug, strerror(fds->pending_error), fds->pending_error);
|
||||
plug_closing_errno(fds->plug, fds->pending_error);
|
||||
}
|
||||
|
||||
static int fdsocket_try_send(FdSocket *fds)
|
||||
@ -270,9 +270,9 @@ static void fdsocket_select_result_input(int fd, int event)
|
||||
fds->infd = -1;
|
||||
|
||||
if (retd < 0) {
|
||||
plug_closing(fds->plug, strerror(errno), errno);
|
||||
plug_closing_errno(fds->plug, errno);
|
||||
} else {
|
||||
plug_closing(fds->plug, NULL, 0);
|
||||
plug_closing_normal(fds->plug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user