Problem with DatagramSocket.receive()?
arajesh
arajesh@india.adventnet.com
Sat Jul 22 00:01:00 GMT 2000
Hi all,
I am using gcj and libgcj version 2.95.1 to compile my java application
(SNMP agent). Inside one of my classes i use a DatagramSocket to receive
packets from remote hosts. I am using the receive(DatagramPacket)
method inside a thread in a while(true) loop. My application hangs
indefinitely in the receive() method. The following is the output i got
from running my application with gdb:
Starting program: /home/guest/AgentTest/finalrfc/a.out
[New Thread 3363 (manager thread)]
[New Thread 3362 (initial thread)]
[New Thread 3364]
[Switching to Thread 3364]
[New Thread 3365]
[New Thread 3366]
Before sock.receive()
In Object getProtocolPacket
Before sock.receive 2()
[New Thread 3367]
Before sock.receive()
In Object getProtocolPacket
Before sock.receive 2()
[New Thread 3368]
[New Thread 3369]
Before sock.receive()
In Object getProtocolPacket
Before sock.receive 2()
[New Thread 3370]
Before sock.receive()
In Object getProtocolPacket
Before sock.receive 2()
[New Thread 3371]
[Switching to Thread 3362 (initial thread)]
Program received signal SIGPWR, Power fail/restart.
0x401fc58b in __sigsuspend (set=0xbffff934)
at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
48 ../sysdeps/unix/sysv/linux/sigsuspend.c: No such file or
directory.
when i did the backtrace i got:
(gdb) bt
#0 0x401fc58b in __sigsuspend (set=0xbffff934)
at ../sysdeps/unix/sysv/linux/sigsuspend.c:48
#1 0x401c01a0 in pthread_cond_wait (cond=0x4017fae4, mutex=0x4017facc)
at restart.h:49
#2 0x40104b10 in _Jv_ThreadWait ()
at ../../../libgcj-2.95.1/libjava/posix-threads.cc:351
#3 0x4008970f in JvRunMain (klass=0x8111de0, argc=1, argv=0xbffffc34)
at ../../../libgcj-2.95.1/libjava/prims.cc:590
#4 0x80e8b9b in main (argc=1, argv=0xbffffc34) at /tmp/ccmtsrN4.i:4
Here 'sock' is the DatagramSocket. The message "Before sock.receive
2()" was used as a debug print statement (using System.out.println) just
before the receive() method. But I am not able to get messages from
print statements which i gave after the receive() method (ie it seems
the packets are never received). I used 'netstat -au' to see the status
of the socket. It appears that whenever i send a packet to the port on
which the socket is listening the Receive queue size keeps increasing
but the packet is never read by the socket ie it seems that the
receive() method locks inside somewhere and never returns (or is it
because the thread that does the receive() call is suspended and never
restarts?). Does gcj has any problem when sockets are used inside
threads? (I am using a lot of threads in my application.).
Could anyone please help me regarding this.
Regards
Rajesh.
More information about the Java
mailing list