cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl + libssh2: strange error on Win64 (compiled using VS 2008)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 29 Dec 2010 01:12:23 +0100 (CET)

On Tue, 28 Dec 2010, S.Gopi wrote:

I'm CC'ing this to the libssh2 list as well. First mail is found here:
http://curl.haxx.se/mail/lib-2010-12/0400.html

[both lists only allow subscribers to post, so if you cross-post you should
be aware]

> In scp_recv function in ssh.c, libssh2_channel_read function is called which
> returns ERROR_EAGAIN which is stored in variable 'nread'. This variable
> nread is declared ssize_t (typedef __int64 for Windows 64 in
> config-win32.h). For reason which I don't know of, nread has an arbitrary
> current value of 4294967259 instead of expected -37 (ERROR_EAGAIN).

> BTW, when I declared ssize_t as int (instead of __int64) in config_win32.h,
> then the problem goes away and the file gets downloaded successfully.

In the public libssh2.h header the ssize_t is typedef'ed to an int. Isn't that
causing this problem?

I would expect that libssh2 needs something similar to this to start with:

diff --git a/include/libssh2.h b/include/libssh2.h
index e011d49..1347b74 100644
--- a/include/libssh2.h
+++ b/include/libssh2.h
@@ -122,7 +122,11 @@ typedef unsigned int uint32_t;
  typedef unsigned __int64 libssh2_uint64_t;
  typedef __int64 libssh2_int64_t;
  # ifndef _SSIZE_T_DEFINED
+#ifdef _WIN64
+typedef __int64 ssize_t;
+#else
  typedef int ssize_t;
+#endif
  # define _SSIZE_T_DEFINED
  #endif
  #else

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-12-29