1
1

Define and use LIBSSH2_INVALID_SOCKET instead of INVALID_SOCKET

INVALID_SOCKET is a special value in Windows representing a
non-valid socket identifier. We were #defining this to -1 on
non-Windows platforms, causing unneccessary namespace pollution.
Let's have our own identifier instead.

Thanks to Matt Lawson for pointing this out.
Этот коммит содержится в:
Peter Stuge 2012-03-02 17:33:42 +01:00
родитель 179d2197dd
Коммит f28264c6a3
3 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -135,9 +135,10 @@ typedef long long libssh2_int64_t;
#ifdef WIN32
typedef SOCKET libssh2_socket_t;
#define LIBSSH2_INVALID_SOCKET INVALID_SOCKET
#else /* !WIN32 */
typedef int libssh2_socket_t;
#define INVALID_SOCKET -1
#define LIBSSH2_INVALID_SOCKET -1
#endif /* WIN32 */
/* Part of every banner, user specified or not */

Просмотреть файл

@ -338,7 +338,7 @@ agent_transact_pageant(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
static int
agent_disconnect_pageant(LIBSSH2_AGENT *agent)
{
agent->fd = INVALID_SOCKET;
agent->fd = LIBSSH2_INVALID_SOCKET;
return 0;
}
@ -771,7 +771,7 @@ libssh2_agent_userauth(LIBSSH2_AGENT *agent,
LIBSSH2_API int
libssh2_agent_disconnect(LIBSSH2_AGENT *agent)
{
if (agent->ops && agent->fd != INVALID_SOCKET)
if (agent->ops && agent->fd != LIBSSH2_INVALID_SOCKET)
return agent->ops->disconnect(agent);
return 0;
}
@ -785,7 +785,7 @@ libssh2_agent_disconnect(LIBSSH2_AGENT *agent)
LIBSSH2_API void
libssh2_agent_free(LIBSSH2_AGENT *agent) {
/* Allow connection freeing when the socket has lost its connection */
if (agent->fd != INVALID_SOCKET) {
if (agent->fd != LIBSSH2_INVALID_SOCKET) {
libssh2_agent_disconnect(agent);
}
agent_free_identities(agent);

Просмотреть файл

@ -675,7 +675,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
if (session->startup_state == libssh2_NB_state_idle) {
_libssh2_debug(session, LIBSSH2_TRACE_TRANS,
"session_startup for socket %d", sock);
if (INVALID_SOCKET == sock) {
if (LIBSSH2_INVALID_SOCKET == sock) {
/* Did we forget something? */
return _libssh2_error(session, LIBSSH2_ERROR_BAD_SOCKET,
"Bad socket provided");