glom r1664 - in trunk: . glom glom/libglom



Author: arminb
Date: Fri Aug 22 11:52:29 2008
New Revision: 1664
URL: http://svn.gnome.org/viewvc/glom?rev=1664&view=rev

Log:
2008-08-22  Armin Burgmeier  <armin openismus com>

	* glom/libglom/connectionpool.cc (discover_first_free_port): Print
	WinSock error code in case the socket() call fails, since socket
	errors are not reported via errno on Windows, so perror does not yield
	a useful error message.

	* glom/main.cc: Initialize WinSock at startup, so that
	discover_first_free_port() can use the socket API.

Modified:
   trunk/ChangeLog
   trunk/glom/libglom/connectionpool.cc
   trunk/glom/main.cc

Modified: trunk/glom/libglom/connectionpool.cc
==============================================================================
--- trunk/glom/libglom/connectionpool.cc	(original)
+++ trunk/glom/libglom/connectionpool.cc	Fri Aug 22 11:52:29 2008
@@ -1149,7 +1149,11 @@
   const int fd = socket(AF_INET, SOCK_STREAM, 0);
   if(fd == -1)
   {
+#ifdef G_OS_WIN32
+    std::cerr << "Create socket: " << WSAGetLastError() << std::endl;
+#else
     perror("Create socket");
+#endif
     return 0;
   }
 

Modified: trunk/glom/main.cc
==============================================================================
--- trunk/glom/main.cc	(original)
+++ trunk/glom/main.cc	Fri Aug 22 11:52:29 2008
@@ -42,6 +42,11 @@
 
 #ifndef G_OS_WIN32
 #include <fontconfig/fontconfig.h> //For cleanup.
+#else
+#define SAVE_DATADIR DATADIR
+#undef DATADIR
+#include <winsock2.h>
+#define DATADIR SAVE_DATADIR
 #endif
 
 namespace Glom
@@ -95,6 +100,14 @@
   //Force some cleanup at exit,
   //to help valgrind to detect memory leaks:
   atexit(__libc_freeres);
+#else
+  WSADATA data;
+  int errcode = WSAStartup(MAKEWORD(2, 0), &data);
+  if(errcode != 0)
+  {
+    std::cerr << "Failed to initialize WinSock: " << errcode << std::endl;
+    return -1;
+  }
 #endif
 
   // TODO: I am not sure why, but this does not work. PYTHONPATH is set
@@ -302,6 +315,9 @@
   //These fail, probably because of previous things that are causing leaks:
   //cairo_debug_reset_static_data(); //This crashes with _cairo_hash_table_destroy: Assertion `hash_table->live_entries == 0' failed.
   //FcFini(); //This crashes with "FcCacheFini: Assertion `fcCacheChains[i] == ((void *)0)' failed."
+#ifdef G_OS_WIN32
+  WSACleanup();
+#endif
 
   return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]