mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-12 00:03:03 +00:00
Fix Windows compilation
Sockets on Windows are unsigned, so define a type GIT_SOCKET which is signed or unsigned depending on the platform. Thanks to Em for his patience with this. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
parent
f978b748bb
commit
74bd343ae8
16
src/netops.c
16
src/netops.c
@ -26,6 +26,7 @@
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <sys/socket.h>
|
# include <sys/socket.h>
|
||||||
|
# include <sys/select.h>
|
||||||
# include <netdb.h>
|
# include <netdb.h>
|
||||||
#else
|
#else
|
||||||
# define _WIN32_WINNT 0x0501
|
# define _WIN32_WINNT 0x0501
|
||||||
@ -143,3 +144,18 @@ int gitno_send(int s, const char *msg, int len, int flags)
|
|||||||
|
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gitno_select_in(gitno_buffer *buf, long int sec, long int usec)
|
||||||
|
{
|
||||||
|
fd_set fds;
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
tv.tv_sec = sec;
|
||||||
|
tv.tv_usec = usec;
|
||||||
|
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
FD_SET(buf->fd, &fds);
|
||||||
|
|
||||||
|
/* The select(2) interface is silly */
|
||||||
|
return select(buf->fd + 1, &fds, NULL, NULL, &tv);
|
||||||
|
}
|
||||||
|
@ -4,11 +4,17 @@
|
|||||||
#ifndef INCLUDE_netops_h__
|
#ifndef INCLUDE_netops_h__
|
||||||
#define INCLUDE_netops_h__
|
#define INCLUDE_netops_h__
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
typedef int GIT_SOCKET;
|
||||||
|
#else
|
||||||
|
typedef unsigned int GIT_SOCKET;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct gitno_buffer {
|
typedef struct gitno_buffer {
|
||||||
char *data;
|
char *data;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
int fd;
|
GIT_SOCKET fd;
|
||||||
} gitno_buffer;
|
} gitno_buffer;
|
||||||
|
|
||||||
void gitno_buffer_setup(gitno_buffer *buf, char *data, unsigned int len, int fd);
|
void gitno_buffer_setup(gitno_buffer *buf, char *data, unsigned int len, int fd);
|
||||||
@ -18,5 +24,6 @@ void gitno_consume_n(gitno_buffer *buf, unsigned int cons);
|
|||||||
|
|
||||||
int gitno_connect(const char *host, const char *port);
|
int gitno_connect(const char *host, const char *port);
|
||||||
int gitno_send(int s, const char *msg, int len, int flags);
|
int gitno_send(int s, const char *msg, int len, int flags);
|
||||||
|
int gitno_select_in(gitno_buffer *buf, long int sec, long int usec);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,10 +23,6 @@
|
|||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
|
||||||
#include <sys/select.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "git2/net.h"
|
#include "git2/net.h"
|
||||||
#include "git2/common.h"
|
#include "git2/common.h"
|
||||||
#include "git2/types.h"
|
#include "git2/types.h"
|
||||||
@ -394,16 +390,8 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
|
|||||||
git_pkt *pkt;
|
git_pkt *pkt;
|
||||||
git_pkt_send_flush(t->socket);
|
git_pkt_send_flush(t->socket);
|
||||||
while (1) {
|
while (1) {
|
||||||
fd_set fds;
|
/* Wait for max. 1 second */
|
||||||
struct timeval tv;
|
error = gitno_select_in(&buf, 1, 0);
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
FD_SET(t->socket, &fds);
|
|
||||||
tv.tv_sec = 1; /* Wait for max. 1 second */
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
|
||||||
/* The select(2) interface is silly */
|
|
||||||
error = select(t->socket + 1, &fds, NULL, NULL, &tv);
|
|
||||||
if (error < GIT_SUCCESS) {
|
if (error < GIT_SUCCESS) {
|
||||||
error = git__throw(GIT_EOSERR, "Error in select");
|
error = git__throw(GIT_EOSERR, "Error in select");
|
||||||
} else if (error == 0) {
|
} else if (error == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user