Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 110683 - wmpop3lb2 doesn't close socket
Summary: wmpop3lb2 doesn't close socket
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Dockapp Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-28 03:37 UTC by roma1390
Modified: 2005-12-01 06:41 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch which may be solves this problem (wmpop3lb2.4.2.diff,755 bytes, patch)
2005-10-28 03:38 UTC, roma1390
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description roma1390 2005-10-28 03:37:59 UTC
wmpop3lb2 doesn't close opened socket.
If you list /proc/[pid]/fd you can see a lot of sockets opened:

/proc/6459/fd $ ls -l
total 6
lr-x------  1 10 10 64 Oct 28 13:31 0 -> /dev/null
lrwx------  1 10 10 64 Oct 28 13:31 1 -> /dev/vc/1
lrwx------  1 10 10 64 Oct 28 13:31 2 -> /dev/vc/1
lrwx------  1 10 10 64 Oct 28 13:31 3 -> socket:[19926851]
lrwx------  1 10 10 64 Oct 28 13:31 4 -> socket:[19926853]
lrwx------  1 10 10 64 Oct 28 13:31 5 -> socket:[19929773]

I submit some patch which close socket in some case unhandled cases.

diff -Naur wmpop3lb2.4.2/wmpop3/Pop3Client.c
wmpop3lb2.4.2-pathed/wmpop3/Pop3Client.c
--- wmpop3lb2.4.2/wmpop3/Pop3Client.c   2002-06-27 16:04:42.000000000 +0200
+++ wmpop3lb2.4.2-pathed/wmpop3/Pop3Client.c    2005-10-28 13:14:44.000000000 +0300
@@ -67,12 +67,18 @@
     pc->server.sin_family = AF_INET;
     pc->hp = gethostbyname(serverName);
     if( pc->hp == 0)
+    {
+        close(pc->s);
         return -1;
+    }
     memcpy( &(pc->server.sin_addr), pc->hp->h_addr, pc->hp->h_length);
     pc->server.sin_port = htons(port);
     if ( connect(pc->s, (struct sockaddr *)&(pc->server)
                                , sizeof(pc->server)) < 0 )
+    {
+        close(pc->s);
         return -1;
+    }
     pc->connected = CONNECTED;
    return 0;
 }


Reproducible: Always
Steps to Reproduce:
1. start wmpop3lb2
2. wait 24 hours
3. ls -l /proc/`/sbin/pidof wmpop3lb`/fd | grep socket | wc -l

Actual Results:  
a opened socket count biger than 10

Expected Results:  
a opened socket count is less than 2.

This patch isn't well tested
Comment 1 roma1390 2005-10-28 03:38:34 UTC
Created attachment 71622 [details, diff]
patch which may be solves this problem
Comment 2 roma1390 2005-11-04 05:44:33 UTC
seems that this patch helped to fix this issue.

$ ps -f x | grep [w]mpo
user     7348 23612  0 Oct28 ?        S      0:07 wmpop3lb
$ date
Fri Nov  4 15:42:26 EET 2005

looks like works very well for a long time:

$ ls -l /proc/`/sbin/pidof wmpop3lb`/fd | grep socket | wc -l
1

$ ls -l /proc/`/sbin/pidof wmpop3lb`/fd | grep socket
lrwx------  1 user user 64 Nov  4 15:43 3 -> socket:[19938664]
Comment 3 Michele Noberasco (RETIRED) gentoo-dev 2005-12-01 06:41:31 UTC
In Portage (as new revision). Thanks for the submission!