[prev in list] [next in list] [prev in thread] [next in thread]
List: squirrelmail-cvs
Subject: [SM-CVS] SF.net SVN: squirrelmail:[14098] trunk/imap_proxy
From: pdontthink () users ! sourceforge ! net
Date: 2011-04-17 22:27:52
Message-ID: E1QBaRc-0006l4-I2 () sfp-svn-4 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 14098
http://squirrelmail.svn.sourceforge.net/squirrelmail/?rev=14098&view=rev
Author: pdontthink
Date: 2011-04-17 22:27:52 +0000 (Sun, 17 Apr 2011)
Log Message:
-----------
Fix server connection synchronization issues in the SELECT cache code (ensure server \
failures result in server connections being fully shut down and removed from \
connection cache)
Modified Paths:
--------------
trunk/imap_proxy/ChangeLog
trunk/imap_proxy/src/select.c
Modified: trunk/imap_proxy/ChangeLog
===================================================================
--- trunk/imap_proxy/ChangeLog 2011-04-17 21:36:29 UTC (rev 14097)
+++ trunk/imap_proxy/ChangeLog 2011-04-17 22:27:52 UTC (rev 14098)
@@ -1,4 +1,9 @@
2011-04-17 Paul Lesniewski <paul@squirrelmail.org>
+ * Fixed server connection synchronization issues in the SELECT
+ cache code (ensure server failures result in server connections
+ being fully shut down and removed from connection cache).
+
+2011-04-17 Paul Lesniewski <paul@squirrelmail.org>
* When NO or BAD response is returned from the server against
a LOGIN or AUTHENTICATE request, we now log the full server
response and pass it back to the client (useful if client
Modified: trunk/imap_proxy/src/select.c
===================================================================
--- trunk/imap_proxy/src/select.c 2011-04-17 21:36:29 UTC (rev 14097)
+++ trunk/imap_proxy/src/select.c 2011-04-17 22:27:52 UTC (rev 14098)
@@ -97,9 +97,12 @@
* may be proxied directly to the server without the use of
* this function.
*
- * -1 - A hard failure condition. The client and server sockets
+ * -1 - A hard client failure condition. The client socket
* should be shut down.
*
+ * -2 - A hard server failure condition. The client and server
+ * sockets should both be shut down.
+ *
* Authors: Dave McMurtrie <davemcmurtrie@hotmail.com>
*
* Notes: The SELECT command string passed into here will be the
@@ -116,6 +119,7 @@
char *Mailbox;
char *Tag;
char *CP;
+ int rc;
char Buf[ BUFSIZE ];
@@ -171,7 +175,11 @@
syslog( LOG_WARNING, "%s: Protocol error. Client sd [%d] sent SELECT command with \
no mailbox name: '%s'", fn, Client->conn->sd, SelectCmd ); snprintf( Buf, sizeof Buf \
- 1, "%s BAD missing required argument to SELECT command\r\n", Tag );
- IMAP_Write( Client->conn, Buf, strlen( Buf ) );
+ if ( IMAP_Write( Client->conn, Buf, strlen( Buf ) ) == -1 )
+ {
+ syslog(LOG_ERR, "%s: IMAP_Write() failed sending data to client on sd [%d]: \
%s", fn, Client->conn->sd, strerror( errno ) ); + return( -1 );
+ }
return( 0 );
}
@@ -188,17 +196,35 @@
*/
IMAPCount->SelectCacheMisses++;
- if ( Populate_Select_Cache( Server, ISC, Mailbox, SelectCmd, SelectCmdLength ) == \
-1 ) + rc = Populate_Select_Cache( Server, ISC, Mailbox, SelectCmd, SelectCmdLength \
); + if ( rc == -1 )
{
return( 1 );
}
+ if ( rc == -2 )
+ {
+ return( -2 );
+ }
- if ( Send_Cached_Select_Response( Client, ISC, Tag ) == -1 )
+ rc = Send_Cached_Select_Response( Client, ISC, Tag );
+ if ( rc == -2 )
{
+ return( -1 );
+ }
+ if ( rc == -1 )
+ {
snprintf( Buf, sizeof Buf - 1, "%s BAD internal proxy server error\r\n", Tag );
- IMAP_Write( Client->conn, Buf, strlen( Buf ) );
+ if ( IMAP_Write( Client->conn, Buf, strlen( Buf ) ) == -1 )
+ {
+ syslog(LOG_ERR, "%s: IMAP_Write() failed sending data to client on sd [%d]: %s", \
fn, Client->conn->sd, strerror( errno ) ); + return( -1 );
+ }
+
+ // soft failure - we sent BAD response, so
+ // now let client decide what to do next
+ //
return( 0 );
- }
+ }
return( 0 );
}
@@ -214,10 +240,23 @@
*/
IMAPCount->SelectCacheHits++;
- if ( Send_Cached_Select_Response( Client, ISC, Tag ) == -1 )
+ rc = Send_Cached_Select_Response( Client, ISC, Tag );
+ if ( rc == -2 )
{
+ return( -1 );
+ }
+ if ( rc == -1 )
+ {
snprintf( Buf, sizeof Buf - 1, "%s BAD internal proxy server error\r\n", Tag );
- IMAP_Write( Client->conn, Buf, strlen( Buf ) );
+ if ( IMAP_Write( Client->conn, Buf, strlen( Buf ) ) == -1 )
+ {
+ syslog(LOG_ERR, "%s: IMAP_Write() failed sending data to client on sd [%d]: %s", \
fn, Client->conn->sd, strerror( errno ) ); + return( -1 );
+ }
+
+ // soft failure - we sent BAD response, so
+ // now let client decide what to do next
+ //
return( 0 );
}
@@ -227,17 +266,35 @@
IMAPCount->SelectCacheMisses++;
- if ( Populate_Select_Cache( Server, ISC, Mailbox, SelectCmd, SelectCmdLength ) \
== -1 ) + rc = Populate_Select_Cache( Server, ISC, Mailbox, SelectCmd, \
SelectCmdLength ); + if ( rc == -1 )
{
return( 1 );
- }
+ }
+ if ( rc == -2 )
+ {
+ return( -2 );
+ }
- if ( Send_Cached_Select_Response( Client, ISC, Tag ) == -1 )
+ rc = Send_Cached_Select_Response( Client, ISC, Tag );
+ if ( rc == -2 )
{
+ return( -1 );
+ }
+ if ( rc == -1 )
+ {
snprintf( Buf, sizeof Buf - 1, "%s BAD internal proxy server error\r\n", Tag );
- IMAP_Write( Client->conn, Buf, strlen( Buf ) );
+ if ( IMAP_Write( Client->conn, Buf, strlen( Buf ) ) == -1 )
+ {
+ syslog(LOG_ERR, "%s: IMAP_Write() failed sending data to client on sd [%d]: \
%s", fn, Client->conn->sd, strerror( errno ) ); + return( -1 );
+ }
+
+ // soft failure - we sent BAD response, so
+ // now let client decide what to do next
+ //
return( 0 );
- }
+ }
return( 0 );
@@ -255,7 +312,8 @@
* ptr to char -- client tag for response
*
* Returns: 0 on success
- * -1 on failure
+ * -1 on soft failure
+ * -2 on hard failure
*
* Authors: Dave McMurtrie <davemcmurtrie@hotmail.com>
*
@@ -273,7 +331,7 @@
strlen( ISC->SelectString ) ) == -1 )
{
syslog( LOG_WARNING, "%s: Failed to send cached SELECT string to client on sd [%d]: \
%s", fn, Client->conn->sd, strerror( errno ) );
- return( -1 );
+ return( -2 );
}
snprintf( SendBuf, sizeof SendBuf - 1, "%s %s", Tag,
@@ -282,7 +340,7 @@
if ( IMAP_Write( Client->conn, SendBuf, strlen( SendBuf ) ) == -1 )
{
syslog( LOG_WARNING, "%s: Failed to send cached SELECT status to client on sd [%d]: \
%s", fn, Client->conn->sd, strerror( errno ) );
- return( -1 );
+ return( -2 );
}
return( 0 );
@@ -304,7 +362,8 @@
* unsigned int -- the length of the select command
*
* Returns: 0 on success
- * -1 on failure
+ * -1 on soft failure
+ * -2 on hard failure
*
* Authors: Dave McMurtrie <davemcmurtrie@hotmail.com>
*
@@ -329,7 +388,7 @@
if ( rc == -1 )
{
syslog( LOG_ERR, "%s: Unable to send SELECT command to IMAP server so can't \
populate cache.", fn );
- return( -1 );
+ return( -2 );
}
BufPtr = ISC->SelectString;
@@ -356,7 +415,7 @@
if ( ( rc == -1 ) || ( rc == 0 ) )
{
syslog( LOG_WARNING, "%s: Unable to read SELECT response from IMAP server so \
can't populate cache.", fn );
- return( -1 );
+ return( -2 );
}
/*
@@ -398,7 +457,7 @@
if ( ! EOS )
{
syslog( LOG_ERR, "%s: Invalid response to SELECT command. Not CRLF terminated.", \
fn );
- return( -1 );
+ return( -2 );
}
*EOS = '\0';
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
-----
squirrelmail-cvs mailing list
List address: squirrelmail-cvs@lists.sourceforge.net
List info (subscribe/unsubscribe/change options): \
https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
Repository: http://squirrelmail.org/svn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic