Re: problem/bug/limitation in uw-client-library

Ico Doornekamp <[email protected]>
Newsgroups gmane.mail.imap.uw.c-client
Message-ID <[email protected]>

* On 2009-10-13 Volker Schwicking <[email protected]> wrote :

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello,
> 
> i just searched the archives but couldnt find any reference regarding
> this bug/problem/limitation in the client-library.
> 
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=478193
> 
> Quick Summary:
> - - apache with 1024+ open file descriptors
> - - php5 using the imap_open-function which utilizes the uw-client-library
> - - imap mailbox with 1024+ emails
> 
> this combinations results in the error-message (on the client-side):
> 
> Unable to create selectable TCP socket (1054 >= 1024)
> 
> Is anyone aware of a patch or some other way to workaround this problem?

I've been bitten by this one as well, time after time after time. I've
created a workaround which closes all apache log filedescriptors in
imap_open, it's a big hack, but works for me. If you're using debian,
you can build and install your own .deb for libc-client including this
patch, but to make sure to pin it to prevent apt-get from installing
newer versions when you're not looking, otherwise your system will break
again after upgrades.

Insert following fragment somewhere in the top of the imap_open
function in src/c-client/imap4r1.c

   
+ { 
+    int fd;
+    int r;
+    char fname[1024]; 
+    char lname[1024]; 
+    for(fd=0; fd<1024; fd++) {
+        snprintf(fname, sizeof(fname),
"/proc/self/fd/%d", fd); 
+        r = readlink(fname, lname, sizeof(lname) - 1);
+        if(r > 0) {
+            lname[r] = 0; 
+            if(strstr(lname, "/var/log/apache2")) {
+                close(fd);
+                printf("%s\n", lname);
+            } 
+        } 
+    } 
+ } 
+

Enjoy,

Ico
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.