mirror of
				https://github.com/libssh2/libssh2.git
				synced 2025-10-30 12:05:34 +03:00 
			
		
		
		
	Use libssh2_socket_t in the ssh-agent stuff.
Define a portability macro SOCKET_BAD which means "invalid socket".
This commit is contained in:
		| @@ -128,7 +128,7 @@ struct _LIBSSH2_AGENT | ||||
| { | ||||
|     LIBSSH2_SESSION *session;  /* the session this "belongs to" */ | ||||
|  | ||||
|     int fd;                             /* -1 when not connected */ | ||||
|     libssh2_socket_t fd; | ||||
|  | ||||
|     struct agent_ops *ops; | ||||
|  | ||||
| @@ -316,7 +316,7 @@ agent_transact_pageant(LIBSSH2_AGENT *agent, agent_transaction_ctx_t transctx) | ||||
| static int | ||||
| agent_disconnect_pageant(LIBSSH2_AGENT *agent) | ||||
| { | ||||
|     agent->fd = -1;        /* Mark as the connection has been closed */ | ||||
|     agent->fd = SOCKET_BAD; | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| @@ -737,7 +737,7 @@ libssh2_agent_userauth(LIBSSH2_AGENT *agent, | ||||
| LIBSSH2_API int | ||||
| 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 0; | ||||
| } | ||||
| @@ -751,7 +751,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 >= 0) { | ||||
|     if (agent->fd != SOCKET_BAD) { | ||||
|         libssh2_agent_disconnect(agent); | ||||
|     } | ||||
|     agent_free_identities(agent); | ||||
|   | ||||
| @@ -151,8 +151,10 @@ static inline int writev(int sock, struct iovec *iov, int nvecs) | ||||
|  | ||||
| #ifdef WIN32 | ||||
| typedef SOCKET libssh2_socket_t; | ||||
| #define SOCKET_BAD ~0 | ||||
| #else /* !WIN32 */ | ||||
| typedef int libssh2_socket_t; | ||||
| #define SOCKET_BAD -1 | ||||
| #endif /* WIN32 */ | ||||
|  | ||||
| /* RFC4253 section 6.1 Maximum Packet Length says: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user