Attachment #24870: YA patch, getting closer, still one issue for bug #56924

View | Details | Raw Unified | Return to bug 56924
Collapse All | Expand All

(-)ssldef.c (+6 lines)
Line     Link Here 
 Lines 115-122    Link Here 
115
	if (rv < 0) {
115
	if (rv < 0) {
116
	    PRErrorCode err = PR_GetError();
116
	    PRErrorCode err = PR_GetError();
117
	    if (err == PR_WOULD_BLOCK_ERROR) {
117
	    if (err == PR_WOULD_BLOCK_ERROR) {
118
		ss->lastWriteBlocked = 1;
118
		return count ? count : rv;
119
		return count ? count : rv;
119
	    }
120
	    }
121
	    ss->lastWriteBlocked = 0;
120
	    MAP_ERROR(PR_CONNECT_ABORTED_ERROR, PR_CONNECT_RESET_ERROR)
122
	    MAP_ERROR(PR_CONNECT_ABORTED_ERROR, PR_CONNECT_RESET_ERROR)
121
	    /* Loser */
123
	    /* Loser */
122
	    return rv;
124
	    return rv;
 Lines 130-135    Link Here 
130
	}
132
	}
131
	break;
133
	break;
132
    }
134
    }
135
    ss->lastWriteBlocked = 0;
133
    return count;
136
    return count;
134
}
137
}
135
138
 Lines 157-164    Link Here 
157
	if (rv < 0) {
160
	if (rv < 0) {
158
	    PRErrorCode err = PR_GetError();
161
	    PRErrorCode err = PR_GetError();
159
	    if (err == PR_WOULD_BLOCK_ERROR) {
162
	    if (err == PR_WOULD_BLOCK_ERROR) {
163
		ss->lastWriteBlocked = 1;
160
		return count ? count : rv;
164
		return count ? count : rv;
161
	    }
165
	    }
166
	    ss->lastWriteBlocked = 0;
162
	    MAP_ERROR(PR_CONNECT_ABORTED_ERROR, PR_CONNECT_RESET_ERROR)
167
	    MAP_ERROR(PR_CONNECT_ABORTED_ERROR, PR_CONNECT_RESET_ERROR)
163
	    /* Loser */
168
	    /* Loser */
164
	    return rv;
169
	    return rv;
 Lines 172-177    Link Here 
172
	}
177
	}
173
	break;
178
	break;
174
    }
179
    }
180
    ss->lastWriteBlocked = 0;
175
    return count;
181
    return count;
176
}
182
}
177
183
(-)sslimpl.h (+1 lines)
Line     Link Here 
 Lines 268-273    Link Here 
268
    unsigned int     detectRollBack   	: 1; /* Detect rollback to SSL v3 */
268
    unsigned int     detectRollBack   	: 1; /* Detect rollback to SSL v3 */
269
    unsigned int     connected		: 1; /* initial handshake is complete. */
269
    unsigned int     connected		: 1; /* initial handshake is complete. */
270
    unsigned int     recvdCloseNotify	: 1; /* received SSL EOF. */
270
    unsigned int     recvdCloseNotify	: 1; /* received SSL EOF. */
271
    unsigned int     lastWriteBlocked   : 1;
271
272
272
    /* version of the protocol to use */
273
    /* version of the protocol to use */
273
    SSL3ProtocolVersion version;
274
    SSL3ProtocolVersion version;
(-)sslsock.c (-17 / +33 lines)
Line     Link Here 
 Lines 34-40    Link Here 
34
 * may use your version of this file under either the MPL or the
34
 * may use your version of this file under either the MPL or the
35
 * GPL.
35
 * GPL.
36
 *
36
 *
37
 * $Id: sslsock.c,v 1.13 2001/02/09 02:11:31 nelsonb%netscape.com Exp $
37
 * $Id: sslsock.c,v 1.12 2001/02/09 00:32:08 nelsonb%netscape.com Exp $
38
 */
38
 */
39
#include "seccomon.h"
39
#include "seccomon.h"
40
#include "cert.h"
40
#include "cert.h"
 Lines 1291-1313    Link Here 
1291
	return 0;	/* don't poll on this socket */
1291
	return 0;	/* don't poll on this socket */
1292
    }
1292
    }
1293
1293
1294
    if ((ret_flags & PR_POLL_WRITE) && 
1294
    if (ss->useSecurity && !ss->connected) {
1295
        ss->useSecurity && 
1295
	/* XXX There needs to be a better test than the following. */
1296
	!ss->connected && 
1296
	if ((ss->handshake == ssl2_BeginClientHandshake) &&
1297
	   /* XXX There needs to be a better test than the following. */
1297
	    (ret_flags & (PR_POLL_READ | PR_POLL_WRITE))) {
1298
	   /* Don't check ss->securityHandshake. */
1298
	    /* The user is waiting to read or write, but the first 
1299
	(ss->handshake || ss->nextHandshake)) {
1299
	    ** handshake record hasn't been sent yet, so lie and 
1300
    	/* The user is trying to write, but the handshake is blocked waiting
1300
	    ** say it's ready so the user will try a read or write.
1301
	 * to read, so tell NSPR NOT to poll on write.
1301
	    */
1302
	 */
1302
	    *out_flags = (ret_flags & (PR_POLL_READ | PR_POLL_WRITE));
1303
	ret_flags ^=  PR_POLL_WRITE;	/* don't select on write. */
1303
	    return ret_flags;
1304
	ret_flags |=  PR_POLL_READ;	/* do    select on read. */
1304
	}
1305
    }
1305
	/* The application is waiting for data to be received, 
1306
1306
	** but the initial handshake is blocked on write.
1307
    if ((ret_flags & PR_POLL_READ) && (SSL_DataPending(fd) > 0)) {
1307
	** The code should select on write, not read.
1308
	*/
1309
	if ((ret_flags & PR_POLL_READ) && ss->lastWriteBlocked) {
1310
	    ret_flags ^=  PR_POLL_READ;		/* don't select on write. */
1311
	    ret_flags |=  PR_POLL_WRITE;        /* do    select on read. */
1312
	} else if ((ret_flags & PR_POLL_WRITE) && 
1313
	       /* XXX There needs to be a better test than the following. */
1314
	       /* Don't check ss->securityHandshake. */
1315
	    (ss->handshake || ss->nextHandshake)) {
1316
	    /* The user is trying to write, but the handshake is blocked 
1317
	    ** waiting to read, so tell NSPR NOT to poll on write.
1318
	    */
1319
	    ret_flags ^=  PR_POLL_WRITE;	/* don't select on write. */
1320
	    ret_flags |=  PR_POLL_READ;	        /* do    select on read. */
1321
	}
1322
    } else if ((ret_flags & PR_POLL_READ) && (SSL_DataPending(fd) > 0)) {
1308
	*out_flags = PR_POLL_READ;	/* it's ready already. */
1323
	*out_flags = PR_POLL_READ;	/* it's ready already. */
1309
1324
	return ret_flags;
1310
    } else if (ret_flags && (fd->lower->methods->poll != NULL)) {
1325
    } 
1326
    if (ret_flags && (fd->lower->methods->poll != NULL)) {
1311
        ret_flags = fd->lower->methods->poll(fd->lower, ret_flags, out_flags);
1327
        ret_flags = fd->lower->methods->poll(fd->lower, ret_flags, out_flags);
1312
    }
1328
    }
1313
1329

Return to bug 56924