Re: pthreads and sockets - Cannot register window class error

2004-05-06 Thread Corinna Vinschen
On May  6 01:47, Hannu E K Nevalainen wrote:
  Just a wild guess, but gethostbyname() is probably not reentrant and
  can't be called from threads like that.
 
  Unless HOST is a numeric IP address, gethostbyname should be properly
  reentrant.  The only time gethostbyname is not thread safe is when it is
  resolving a numeric IP.
 
  cgf
 
  Is this specifically for cygwin, or common place?

Cygwin.  Common is what is described in SUSv3.

Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Co-Project Leader  mailto:[EMAIL PROTECTED]
Red Hat, Inc.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-06 Thread Brian Ford
On Thu, 6 May 2004, Jacek Trzmiel wrote:

 Nevertheless ThreadingTest.cpp posted here:

 http://cygwin.com/ml/cygwin/2004-05/msg00178.html

 still sometimes fails, even with 20040504 snapshot:

  $ g++ ThreadingTest.cpp -lpthread -o ThreadingTest.exe  ./ThreadingTest.exe
  238 [win] ThreadingTest 1696 Winmain: Cannot register window class, Win32 
  error 1410
  896 [win] ThreadingTest 1696 Winmain: Cannot register window class, Win32 
  error 1410

It's an obvious race condition in winsup/cygwin/window.cc (gethwnd):
ourhwnd.  I'm not quite sure how to fix it yet, and I've got to do real
work now.  So, have at it :-).

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



RE: pthreads and sockets - Cannot register window class error

2004-05-06 Thread Hannu E K Nevalainen
 From: Corinna Vinschen
 Sent: Thursday, May 06, 2004 9:59 AM

 On May  6 01:47, Hannu E K Nevalainen wrote:
   Just a wild guess, but gethostbyname() is probably not reentrant and
   can't be called from threads like that.
  
   Unless HOST is a numeric IP address, gethostbyname should be properly
   reentrant.  The only time gethostbyname is not thread safe is 
   when it is resolving a numeric IP.
  
   cgf
  
   Is this specifically for cygwin, or common place?
 
 Cygwin.  Common is what is described in SUSv3.
 
 Corinna

 Thanks a lot. :-)
Beeing a somewhat knowledgeable newbie is a pain at times.
(What you do *not* know doesn't hurt you...)

/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E

** on a mailing list; please keep replies on that particular list **

-- printf(LocalTime: UTC+%02d\n,(DST)? 2:1); --
--END OF MESSAGE--

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Arash Partow
Hi,
I can't replicate your problem, but I know where it is coming from,
basically standard windows winsock is not geared up to handle that man
socket connections. When a socket is made and then closed the socket
actually stays open for about 240-300 seconds depending on your
registry settings, this is so that winsock can make sure the
connection has been properly closed off.
Whilst this 240-300 seconds is passing by the socket is actually still
alive meaning the memory it occupies is still valid, its not until the
240 seconds has passed does winsock go and clean up the instance of
the socket.
what you are seeing is that basically as you run your program more and
more times, you are creating sockets in memory, every time the socket
is closed YOU think that the socket is cleaned up but its not, and so
you basically loose a bit of memory until the timeout for the socket
has occurred, i guess through debugging where you run and re-run your
test app you have run out of RAM so you see these errors.
this explains the whole thing:
http://www.winguides.com/registry/display.php/878/
The only thing you can do is not make so many client socket connections
or use windows server which has a winsock geared for server like behavior,
or make the modifications mentioned in the article, or just simply use *bsd
or linux tcp/ip stack.

Regards

Arash Partow
__
Be one who knows what they don't know,
Instead of being one who knows not what they don't know,
Thinking they know everything about all things.
http://www.partow.net


Hi again,
I have problem using pthreads together with sockets on cygwin 1.5.9-1,
win2k sp4.
Here is minimal app where I can reproduce errors.  It will start 70
threads and fetch http://example.org/ page on every each of them. Please 
change host on line:
   const char *HOST = example.org;
if you don't want to DDOS it ;)

--- ThreadingTest.cpp -
#include iostream
#include pthread.h
#include stdlib.h
#include stdio.h
#include unistd.h
#include sys/types.h
#include sys/socket.h
#include netinet/in.h
#include netdb.h
#include string.h
#include assert.h
using std::cout;
using std::endl;
const char *HOST= example.org;
const int   PORT= 80;
const char *MESSAGE = GET / HTTP/1.0\r\n\r\n;
void sendall( int sd, const char *data, int datalen )
{
   assert( data );
   assert( datalen = 0 );
   while(datalen0) {
   int sent = send(sd, data, datalen, 0);
   if( sent == -1) {
   perror(send);
   exit(1);
   }
   data += sent;
   datalen -= sent;
   assert( datalen=0 );
   }
}
void recvandprintall( int sd )
{
   const int bufferlen = 65536;
   char buffer[bufferlen];
   while(true) {
   int got = recv(sd, buffer, bufferlen, 0);
   if(got == -1) {
   perror(recv);
   exit(1);
   }
   if(got==0) {
   cout  got\n;
   cout.flush();
   break;
   }
   }
}
void test()
{
   /* go find out about the desired host machine */
   struct hostent *he = gethostbyname(HOST);
   if (he == 0) {
   perror(gethostbyname);
   exit(1);
   }
   assert( he-h_addrtype == AF_INET );
   assert( he-h_addr_list[0] );
   /* fill in the socket structure with host information */
   struct sockaddr_in pin;
   memset( pin, 0, sizeof(pin) );
   pin.sin_family = AF_INET;
   pin.sin_addr.s_addr = ((struct in_addr *)(he-h_addr))-s_addr;
   pin.sin_port = htons(PORT);
   /* grab an Internet domain socket */
   int sd;
   if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
   perror(socket);
   exit(1);
   }
   /* connect to PORT on HOST */
   if (connect(sd,(struct sockaddr *)  pin, sizeof(pin)) == -1) {
   perror(connect);
   exit(1);
   }
   /* send a message to the server PORT on machine HOST */
   sendall( sd, MESSAGE, strlen(MESSAGE) );
   /* shutdown writing part of socket */
   shutdown( sd, SHUT_WR );
   /* wait for data to come back from the server and print it */
   recvandprintall( sd );
   close(sd);
}
void *task(void *arg)
{
   test();
   return NULL;
}
int main()
{
   const int threads = 70;
   pthread_t threadTable[threads];
   for(int i=0; ithreads; ++i)
   {
   if(pthread_create(threadTable[i], NULL, task, (void *)(i+1)) !=
0)
   {
   cout  pthread_create() error  endl;
   abort();
   }
   }
   for(int i=0; ithreads; ++i)
   {
   pthread_join( threadTable[i], NULL );   }
   return 0;
}
--- ThreadingTest.cpp -
Compile and run it this way:
$ g++ ThreadingTest.cpp -lpthread -o ThreadingTest.exe  
./ThreadingTest.exe
got
got
got
[...]
If everything goes right, then it prints got 70 times and quits.
However sometimes it fails this way (you may need to run it several
times to reproduce error):
$ g++ ThreadingTest.cpp -lpthread -o ThreadingTest.exe  
./ThreadingTest.exe
285 [win] ThreadingTest 1476 Winmain: Cannot register window class, 

RE: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Dave Korn
 -Original Message-
 From: cygwin-owner On Behalf Of Arash Partow
 Sent: 05 May 2004 12:04


 I can't replicate your problem, but I know where it is coming from,
 basically standard windows winsock is not geared up to handle that man
 socket connections. When a socket is made and then closed the socket
 actually stays open for about 240-300 seconds depending on your
 registry settings, this is so that winsock can make sure the
 connection has been properly closed off.

 or just  simply use *bsd or linux tcp/ip stack.


  Nope, that won't help, unless of course it's because *bsd/linux already
have their stacks tuned for server-like applications by default.  This delay
isn't a windoze-specific feature, it's a generic and universal feature of
all TCP/IP implementations: google for TIME_WAIT and 2MSL and read RFC
793 to find out more, also 

http://www.developerweb.net/sock-faq/detail.php?id=13


cheers, 
  DaveK
-- 
Can't think of a witty .sigline today


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Brian Dessent
Jacek Trzmiel wrote:

 void test()
 {
 /* go find out about the desired host machine */
 struct hostent *he = gethostbyname(HOST);
 if (he == 0) {
 perror(gethostbyname);
 exit(1);
 }

Just a wild guess, but gethostbyname() is probably not reentrant and
can't be called from threads like that.

Brian

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Reini Urban
Arash Partow schrieb:
I can't replicate your problem, but I know where it is coming from,
basically standard windows winsock is not geared up to handle that man
socket connections. When a socket is made and then closed the socket
actually stays open for about 240-300 seconds depending on your
registry settings, this is so that winsock can make sure the
connection has been properly closed off.
Whilst this 240-300 seconds is passing by the socket is actually still
alive meaning the memory it occupies is still valid, its not until the
240 seconds has passed does winsock go and clean up the instance of
the socket.
what you are seeing is that basically as you run your program more and
more times, you are creating sockets in memory, every time the socket
is closed YOU think that the socket is cleaned up but its not, and so
you basically loose a bit of memory until the timeout for the socket
has occurred, i guess through debugging where you run and re-run your
test app you have run out of RAM so you see these errors.
this explains the whole thing:
http://www.winguides.com/registry/display.php/878/
$ regtool -i set 
/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/TcpTimedWaitDelay 
30

But we already found out that the culprit was Norton Firewall, closing 
your socket, wasn't it?
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/


Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Jacek Trzmiel

Hi Brian,

  void test()
  {
  /* go find out about the desired host machine */
  struct hostent *he = gethostbyname(HOST);
  if (he == 0) {
  perror(gethostbyname);
  exit(1);
  }
 
 Just a wild guess, but gethostbyname() is probably not reentrant and
 can't be called from threads like that.

Thanks, it may be:
http://www.opengroup.org/onlinepubs/009695399/functions/gethostbyaddr.html

The gethostbyname() function need not be reentrant. A function that is
not required to be reentrant is not required to be thread-safe.

This can explain those errors:
gethostbynamegethostbyname: Operation not permitted

However Winmain: Cannot register window class, Win32 error 1410 still
happens with modified code:

--- ThreadingTest.cpp -
#include iostream
#include pthread.h
#include stdlib.h

#include stdio.h
#include unistd.h
#include sys/types.h
#include sys/socket.h
#include netinet/in.h
#include netdb.h
#include string.h
#include assert.h

using std::cout;
using std::endl;


const char *HOST= example.org;
const int   PORT= 80;
const char *MESSAGE = GET / HTTP/1.0\r\n\r\n;

struct hostent *g_he = 0;


void sendall( int sd, const char *data, int datalen )
{
assert( data );
assert( datalen = 0 );
while(datalen0) {
int sent = send(sd, data, datalen, 0);
if( sent == -1) {
perror(send);
exit(1);
}
data += sent;
datalen -= sent;
assert( datalen=0 );
}
}


void recvandprintall( int sd )
{
const int bufferlen = 65536;
char buffer[bufferlen];

while(true) {
int got = recv(sd, buffer, bufferlen, 0);
if(got == -1) {
perror(recv);
exit(1);
}
if(got==0) {
cout  got\n;
cout.flush();
break;
}
}
}


void test()
{
/* fill in the socket structure with host information */
struct sockaddr_in pin;
memset( pin, 0, sizeof(pin) );
pin.sin_family = AF_INET;
pin.sin_addr.s_addr = ((struct in_addr *)(g_he-h_addr))-s_addr;
pin.sin_port = htons(PORT);

/* grab an Internet domain socket */
int sd;
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror(socket);
exit(1);
}

/* connect to PORT on HOST */
if (connect(sd,(struct sockaddr *)  pin, sizeof(pin)) == -1) {
perror(connect);
exit(1);
}

/* send a message to the server PORT on machine HOST */
sendall( sd, MESSAGE, strlen(MESSAGE) );

/* shutdown writing part of socket */
shutdown( sd, SHUT_WR );

/* wait for data to come back from the server and print it */
recvandprintall( sd );

close(sd);
}


void *task(void *arg)
{
test();
return NULL;
}


int main()
{
/* go find out about the desired host machine */
g_he = gethostbyname(HOST);
if(g_he == 0)
{
perror(gethostbyname);
exit(1);
}
assert( g_he-h_addrtype == AF_INET );
assert( g_he-h_addr_list[0] );

const int threads = 70;
pthread_t threadTable[threads];

for(int i=0; ithreads; ++i)
{
if(pthread_create(threadTable[i], NULL, task, (void *)(i+1)) !=
0)
{
cout  pthread_create() error  endl;
abort();
}
}

for(int i=0; ithreads; ++i)
{
pthread_join( threadTable[i], NULL );
}

return 0;
}
--- ThreadingTest.cpp -


Best regards,
Jacek.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Jacek Trzmiel

Hi Reini,

 But we already found out that the culprit was Norton Firewall, closing
 your socket, wasn't it?

NIS is gone.

Best regards,
Jacek.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Christopher Faylor
On Wed, May 05, 2004 at 05:38:35AM -0700, Brian Dessent wrote:
Jacek Trzmiel wrote:

 void test()
 {
 /* go find out about the desired host machine */
 struct hostent *he = gethostbyname(HOST);
 if (he == 0) {
 perror(gethostbyname);
 exit(1);
 }

Just a wild guess, but gethostbyname() is probably not reentrant and
can't be called from threads like that.

Unless HOST is a numeric IP address, gethostbyname should be properly
reentrant.  The only time gethostbyname is not thread safe is when it is
resolving a numeric IP.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Jacek Trzmiel

Hi,

 I can't replicate your problem, but I know where it is coming from,
 basically standard windows winsock is not geared up to handle that man
 socket connections. When a socket is made and then closed the socket
 actually stays open for about 240-300 seconds depending on your
 registry settings, this is so that winsock can make sure the
 connection has been properly closed off.

As Dave wrote - normal TCP behaviour.

 what you are seeing is that basically as you run your program more and
 more times, you are creating sockets in memory, every time the socket
 is closed YOU think that the socket is cleaned up but its not, and so
 you basically loose a bit of memory until the timeout for the socket
 has occurred, i guess through debugging where you run and re-run your
 test app you have run out of RAM so you see these errors.

- Program failed with second run after reboot - netstat showed 140
sockets in TIME_WAIT state.
- Program did run succesfully some tries later when netstat showed 484
sockets in TIME_WAIT state.

 The only thing you can do is not make so many client socket connections

Same error did happen with 20 connections. I would not describe it as
many.

 or use windows server which has a winsock geared for server like behavior,
 or make the modifications mentioned in the article, or just simply use *bsd
 or linux tcp/ip stack.

Sure I can use other stack.  But I prefer to find out exactly where and
why error happens, so I can avoid it in the future.

Best regards,
Jacek.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Jacek Trzmiel

  void test()
  {
  /* go find out about the desired host machine */
  struct hostent *he = gethostbyname(HOST);
  if (he == 0) {
  perror(gethostbyname);
  exit(1);
  }
 
 Just a wild guess, but gethostbyname() is probably not reentrant and
 can't be called from threads like that.

Christopher Faylor wrote:
 Unless HOST is a numeric IP address, gethostbyname should be properly
 reentrant.  The only time gethostbyname is not thread safe is when it is
 resolving a numeric IP.


--- GetHostByNameTest.cpp --
#include iostream
#include pthread.h
#include stdlib.h
#include stdio.h
#include sys/socket.h
#include netdb.h
#include assert.h

using std::cout;
using std::endl;


const char *HOST= example.org;


void test()
{
for(int i=0; i100; ++i)
{
/* go find out about the desired host machine */
struct hostent *he = gethostbyname(HOST);
if(he == 0)
{
perror(gethostbyname);
exit(1);
}
assert( he-h_addrtype == AF_INET );
assert( he-h_addr_list[0] );
}
}


void *task(void *arg)
{
test();
return NULL;
}


int main()
{
const int threads = 70;
pthread_t threadTable[threads];

for(int i=0; ithreads; ++i)
{
if(pthread_create(threadTable[i], NULL, task, (void *)(i+1)) !=
0)
{
cout  pthread_create() error  endl;
abort();
}
}

for(int i=0; ithreads; ++i)
{
pthread_join( threadTable[i], NULL );
}

return 0;
}
--- GetHostByNameTest.cpp --


 $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe  
 ./GetHostByNameTest.exe

 $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe  
 ./GetHostByNameTest.exe
 
 $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe  
 ./GetHostByNameTest.exe
 
 $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe  
 ./GetHostByNameTest.exe
 
 $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe  
 ./GetHostByNameTest.exe
 
 $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe  
 ./GetHostByNameTest.exe
 gethostbyname: Operation not permitted
 gethostbynamegethostbynamegethostbynamegethostbynamegethostbyname: : : : : Operation 
 not permittedOperation  not permittedOperation not permittedOperation not 
 permittedOperation not permitted

Win2k SP4 + hotfixes.
Can someone reproduce it?

Best regards,
Jacek.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Steve Thompson
On Wed, 5 May 2004, Christopher Faylor wrote:

 On Wed, May 05, 2004 at 05:38:35AM -0700, Brian Dessent wrote:
 Jacek Trzmiel wrote:
 
  void test()
  {
  /* go find out about the desired host machine */
  struct hostent *he = gethostbyname(HOST);
  if (he == 0) {
  perror(gethostbyname);
  exit(1);
  }
 
 Just a wild guess, but gethostbyname() is probably not reentrant and
 can't be called from threads like that.

 Unless HOST is a numeric IP address, gethostbyname should be properly
 reentrant.  The only time gethostbyname is not thread safe is when it is
 resolving a numeric IP.

I believe that gethostbyname(), since it is returning a pointer to a
statically allocated structure, cannot be thread safe under any
circumstances. I always wrap it with a mutex until I'm done with the
hostent structure.

Steve

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



RE: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Hannu E K Nevalainen
 From: Christopher Faylor
 Sent: Wednesday, May 05, 2004 11:04 PM

 On Wed, May 05, 2004 at 05:38:35AM -0700, Brian Dessent wrote:
 Jacek Trzmiel wrote:
 
  void test()
  {
  /* go find out about the desired host machine */
  struct hostent *he = gethostbyname(HOST);
  if (he == 0) {
  perror(gethostbyname);
  exit(1);
  }
 
 Just a wild guess, but gethostbyname() is probably not reentrant and
 can't be called from threads like that.

 Unless HOST is a numeric IP address, gethostbyname should be properly
 reentrant.  The only time gethostbyname is not thread safe is when it is
 resolving a numeric IP.

 cgf

 Is this specifically for cygwin, or common place?

Trying to find out - /MORE - not so cygwin'ish follows/


The following indicates to me that numeric, i.e. dotted decimal input,
causes unspecified behaviour:

http://www.opengroup.org/onlinepubs/009695399/functions/gethostbyaddr.html
 The name argument of gethostbyname() shall be a node name; the behavior
 of gethostbyname() when passed a numeric address string is unspecified.
 For IPv4, a numeric address string shall be in the dotted-decimal notation
 described in inet_addr() .

 IMO the middle of this paragraph is incongruous! WHAT are they trying to
say?

Besides this they seem to be saying that nothing has to be reentrant nor
thread safe.

...and then there is:

 The getaddrinfo() and getnameinfo() functions are preferred over the
 gethostbyaddr() and gethostbyname() functions.

/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E

** on a mailing list; please keep replies on that particular list **

-- printf(LocalTime: UTC+%02d\n,(DST)? 2:1); --
--END OF MESSAGE--


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Brian Ford
On Thu, 6 May 2004, Jacek Trzmiel wrote:

  $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe 
  ./GetHostByNameTest.exe gethostbyname: Operation not permitted

 Win2k SP4 + hotfixes.
 Can someone reproduce it?

Sure looks alot like this:

http://www.cygwin.com/ml/cygwin/2004-04/msg00545.html

have you tried a snapshot?

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Brian Ford
On Wed, 5 May 2004, Steve Thompson wrote:

 On Wed, 5 May 2004, Christopher Faylor wrote:

  Unless HOST is a numeric IP address, gethostbyname should be properly
  reentrant.  The only time gethostbyname is not thread safe is when it is
  resolving a numeric IP.

 I believe that gethostbyname(), since it is returning a pointer to a
 statically allocated structure, cannot be thread safe under any
 circumstances. I always wrap it with a mutex until I'm done with the
 hostent structure.

That's a good portable practice.  But, if your going to essentially call
cgf a lyer, please at least check the source.  He uses a thread specific
buffer to return that data.  It's obvious if you look.

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



RE: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Hannu E K Nevalainen
 From: Brian Ford
 Sent: Thursday, May 06, 2004 1:55 AM

 On Thu, 6 May 2004, Jacek Trzmiel wrote:

   $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe 
   ./GetHostByNameTest.exe gethostbyname: Operation not permitted
 
  Win2k SP4 + hotfixes.
  Can someone reproduce it?

 Sure looks alot like this:

 http://www.cygwin.com/ml/cygwin/2004-04/msg00545.html

 have you tried a snapshot?

DITO.

$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$  ./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$ g++ ghTest.cpp  -lpthread -o GetHostByNameTest.exe 
./GetHostByNameTest.exe
$

... no errors as it seems.

$ uname -a
CYGWIN_NT-5.0 P450 1.5.10s(0.114/4/2) 20040504 23:37:33 i686 unknown unknown
Cygwin

...as of a few minutes before the test.
(on Win2K adv server, SP4 + all updates - no virii ;-) knock on wood!)

/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E

** on a mailing list; please keep replies on that particular list **

-- printf(LocalTime: UTC+%02d\n,(DST)? 2:1); --
--END OF MESSAGE--


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Steve Thompson
On Wed, 5 May 2004, Brian Ford wrote:

 On Wed, 5 May 2004, Steve Thompson wrote:

  On Wed, 5 May 2004, Christopher Faylor wrote:
 
   Unless HOST is a numeric IP address, gethostbyname should be properly
   reentrant.  The only time gethostbyname is not thread safe is when it is
   resolving a numeric IP.
 
  I believe that gethostbyname(), since it is returning a pointer to a
  statically allocated structure, cannot be thread safe under any
  circumstances. I always wrap it with a mutex until I'm done with the
  hostent structure.

 That's a good portable practice.  But, if your going to essentially call
 cgf a lyer, please at least check the source.  He uses a thread specific
 buffer to return that data.  It's obvious if you look.

Heaven forbid that I should do that; it certainly wasn't my meaning.
Apologies to cgf if it was taken that way. In any event, relying on a
feature that is particular to one implementation will always bite you in
the end.

Steve

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Jacek Trzmiel

Hi Brian,

   $ g++ GetHostByNameTest.cpp -lpthread -o GetHostByNameTest.exe 
   ./GetHostByNameTest.exe gethostbyname: Operation not permitted
 
  Win2k SP4 + hotfixes.
  Can someone reproduce it?
 
 Sure looks alot like this:
 http://www.cygwin.com/ml/cygwin/2004-04/msg00545.html
 have you tried a snapshot?

Thanks, it works with latest snapshot.  Should have checked this
before...

Nevertheless ThreadingTest.cpp posted here:

http://cygwin.com/ml/cygwin/2004-05/msg00178.html

still sometimes fails, even with 20040504 snapshot:

 $ g++ ThreadingTest.cpp -lpthread -o ThreadingTest.exe  ./ThreadingTest.exe
 238 [win] ThreadingTest 1696 Winmain: Cannot register window class, Win32 error 
 1410
 896 [win] ThreadingTest 1696 Winmain: Cannot register window class, Win32 error 
 1410

 $ g++ ThreadingTest.cpp -lpthread -o ThreadingTest.exe  ./ThreadingTest.exe
  10 [win] ThreadingTest 732 Winmain: Cannot register window class, Win32 error 
 1410
8362 [win] ThreadingTest 732 Winmain: Cannot register window class, Win32 error 
 1410
 D:\Sources\Test\ThreadingTest.exe (1360): *** WFSO failed, Win32 error 6
   11725 [win] ThreadingTest 732 Winmain: Cannot register window class, Win32 error 
 1410

Best regards,
Jacek.

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: pthreads and sockets - Cannot register window class error

2004-05-05 Thread Christopher Faylor
On Wed, May 05, 2004 at 07:01:01PM -0500, Brian Ford wrote:
On Wed, 5 May 2004, Steve Thompson wrote:
 On Wed, 5 May 2004, Christopher Faylor wrote:
Unless HOST is a numeric IP address, gethostbyname should be properly
reentrant.  The only time gethostbyname is not thread safe is when it
is resolving a numeric IP.

I believe that gethostbyname(), since it is returning a pointer to a
statically allocated structure, cannot be thread safe under any
circumstances.  I always wrap it with a mutex until I'm done with the
hostent structure.

That's a good portable practice.  But, if your going to essentially
call cgf a liar, please at least check the source.  He uses a thread
specific buffer to return that data.  It's obvious if you look.

It's not actually me that does this.  This practice was developed by
the people who took the first stab at making cygwin thread safe.  My
recent signal work did make it a little easier to use thread local
storage however.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/