1
1

Use libssh2_socket_t in the ssh-agent stuff.

Define a portability macro SOCKET_BAD which means "invalid socket".
Этот коммит содержится в:
Daiki Ueno 2009-12-24 19:45:57 +09:00
родитель 0b6e37872d
Коммит 8436e45ea6
2 изменённых файлов: 6 добавлений и 4 удалений

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

@ -128,7 +128,7 @@ struct _LIBSSH2_AGENT
{ {
LIBSSH2_SESSION *session; /* the session this "belongs to" */ LIBSSH2_SESSION *session; /* the session this "belongs to" */
int fd; /* -1 when not connected */ libssh2_socket_t fd;
struct agent_ops *ops; struct agent_ops *ops;
@ -316,7 +316,7 @@ agent_transact_pageant(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx)
static int static int
agent_disconnect_pageant(LIBSSH2_AGENT *agent) agent_disconnect_pageant(LIBSSH2_AGENT *agent)
{ {
agent->fd = -1; /* Mark as the connection has been closed */ agent->fd = SOCKET_BAD;
return 0; return 0;
} }
@ -737,7 +737,7 @@ libssh2_agent_userauth(LIBSSH2_AGENT *agent,
LIBSSH2_API int LIBSSH2_API int
libssh2_agent_disconnect(LIBSSH2_AGENT *agent) libssh2_agent_disconnect(LIBSSH2_AGENT *agent)
{ {
if (agent->ops && agent->fd >= 0) if (agent->ops && agent->fd != SOCKET_BAD)
return agent->ops->disconnect(agent); return agent->ops->disconnect(agent);
return 0; return 0;
} }
@ -751,7 +751,7 @@ libssh2_agent_disconnect(LIBSSH2_AGENT *agent)
LIBSSH2_API void LIBSSH2_API void
libssh2_agent_free(LIBSSH2_AGENT *agent) { libssh2_agent_free(LIBSSH2_AGENT *agent) {
/* Allow connection freeing when the socket has lost its connection */ /* Allow connection freeing when the socket has lost its connection */
if (agent->fd >= 0) { if (agent->fd != SOCKET_BAD) {
libssh2_agent_disconnect(agent); libssh2_agent_disconnect(agent);
} }
agent_free_identities(agent); agent_free_identities(agent);

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

@ -151,8 +151,10 @@ static inline int writev(int sock, struct iovec *iov, int nvecs)
#ifdef WIN32 #ifdef WIN32
typedef SOCKET libssh2_socket_t; typedef SOCKET libssh2_socket_t;
#define SOCKET_BAD ~0
#else /* !WIN32 */ #else /* !WIN32 */
typedef int libssh2_socket_t; typedef int libssh2_socket_t;
#define SOCKET_BAD -1
#endif /* WIN32 */ #endif /* WIN32 */
/* RFC4253 section 6.1 Maximum Packet Length says: /* RFC4253 section 6.1 Maximum Packet Length says: