~ubuntu-branches/ubuntu/hardy/lighttpd/hardy

« back to all changes in this revision

Viewing changes to src/connections.c

  • Committer: Bazaar Package Importer
  • Author(s): Jeremie Corbier
  • Date: 2006-09-22 19:16:08 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060922191608-i9jngvf1wtf3j5rd
Tags: 1.4.12~20060907-1ubuntu1
Merge from debian unstable:
-> Keep the additional dependency on libterm-readline-perl-perl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
        server_socket *srv_sock = con->srv_socket;
199
199
#endif
200
200
 
201
 
        b = chunkqueue_get_append_buffer(con->read_queue);
202
 
        buffer_prepare_copy(b, 4096);
203
 
 
204
201
#ifdef USE_OPENSSL
205
202
        if (srv_sock->is_ssl) {
 
203
                /* don't resize the buffer if we were in SSL_ERROR_WANT_* */
 
204
                if (!con->is_ssl_error_want) {
 
205
                        b = chunkqueue_get_append_buffer(con->read_queue);
 
206
                        buffer_prepare_copy(b, SSL_pending(con->ssl) + (16 * 1024)); /* the pending bytes + 16kb */
 
207
                } else {
 
208
                        /* we have to get the last buffer */
 
209
                        chunk *c;
 
210
 
 
211
                        for (c = con->read_queue->first; c && c->next; c = c->next);
 
212
 
 
213
                        if (!c) {
 
214
                                b = chunkqueue_get_append_buffer(con->read_queue);
 
215
                                buffer_prepare_copy(b, SSL_pending(con->ssl) + (16 * 1024)); /* the pending bytes + 16kb */
 
216
                        } else {
 
217
                                log_error_write(srv, __FILE__, __LINE__, "s", 
 
218
                                                "(debug) re-using last buffer after a SSL_ERROR_WANT_READ - good, please report this to jan@kneschke.de");
 
219
 
 
220
                                b = c->mem;
 
221
                        }
 
222
                }
206
223
                len = SSL_read(con->ssl, b->ptr, b->size - 1);
 
224
                con->is_ssl_error_want = 0; /* reset */
207
225
        } else {
208
226
                if (ioctl(con->fd, FIONREAD, &toread)) {
209
227
                        log_error_write(srv, __FILE__, __LINE__, "sd", 
211
229
                                        con->fd);
212
230
                        return -1;
213
231
                }
 
232
                b = chunkqueue_get_append_buffer(con->read_queue);
214
233
                buffer_prepare_copy(b, toread);
215
234
 
216
235
                len = read(con->fd, b->ptr, b->size - 1);
217
236
        }
218
237
#elif defined(__WIN32)
 
238
        b = chunkqueue_get_append_buffer(con->read_queue);
 
239
        buffer_prepare_copy(b, 4 * 1024);
219
240
        len = recv(con->fd, b->ptr, b->size - 1, 0);
220
241
#else
221
242
        if (ioctl(con->fd, FIONREAD, &toread)) {
224
245
                                con->fd);
225
246
                return -1;
226
247
        }
 
248
        b = chunkqueue_get_append_buffer(con->read_queue);
227
249
        buffer_prepare_copy(b, toread);
228
250
 
229
251
        len = read(con->fd, b->ptr, b->size - 1);
238
260
                        
239
261
                        switch ((r = SSL_get_error(con->ssl, len))) {
240
262
                        case SSL_ERROR_WANT_READ:
 
263
                        case SSL_ERROR_WANT_WRITE:
 
264
                                con->is_ssl_error_want = 1;
241
265
                                return 0;
242
266
                        case SSL_ERROR_SYSCALL:
243
267
                                /**
777
801
#else
778
802
        memset(con->cond_cache, 0, sizeof(cond_cache_t) * srv->config_context->used);
779
803
#endif
 
804
 
 
805
#ifdef USE_OPENSSL
 
806
        con->is_ssl_error_want = 0;
 
807
#endif
780
808
        
781
809
        con->header_len = 0;
782
810
        con->in_error_handler = 0;