changeset 203:c9da5900c79e

nginx-0.0.1-2003-12-02-08:47:29 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 02 Dec 2003 05:47:29 +0000
parents 74994aeef848
children e0bcfb77d6c7
files src/event/ngx_event.h src/http/ngx_http_cache.c src/http/ngx_http_cache.h src/os/unix/ngx_freebsd_sendfile_chain.c
diffstat 4 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -25,9 +25,6 @@ struct ngx_event_s {
     /* TODO rename to handler, move flags to struct start */
     void           (*event_handler)(ngx_event_t *ev);
 
-    void            *context;
-    char            *action;
-
     u_int            index;
 
     /* queue in mutex(), aio_read(), aio_write()  */
--- a/src/http/ngx_http_cache.c
+++ b/src/http/ngx_http_cache.c
@@ -47,8 +47,14 @@ ngx_http_cache_t *ngx_http_cache_get(ngx
             && c[i].key.len == key->len
             && ngx_rstrncmp(c[i].key.data, key->data, key->len) == 0)
         {
+#if 0
+            if (c[i].expired) {
+                ngx_mutex_unlock(&hash->mutex);
+                return (void *) NGX_AGAIN;
+            }
+#endif
+
             c[i].refs++;
-            ngx_mutex_unlock(&hash->mutex);
 
             if ((!(c[i].notify && (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)))
                 && (ngx_cached_time - c[i].updated >= hash->update))
@@ -56,6 +62,8 @@ ngx_http_cache_t *ngx_http_cache_get(ngx
                 c[i].expired = 1;
             }
 
+            ngx_mutex_unlock(&hash->mutex);
+
             if (cleanup) {
                 cleanup->data.cache.hash = hash;
                 cleanup->data.cache.cache = &c[i];
@@ -217,6 +225,12 @@ void ngx_http_cache_free(ngx_http_cache_
 }
 
 
+void ngx_http_cache_lock(ngx_http_cache_hash_t *hash, ngx_http_cache_t *cache)
+{
+    ngx_mutex_lock(&hash->mutex);
+}
+
+
 void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash,
                            ngx_http_cache_t *cache, ngx_log_t *log)
 {
@@ -234,9 +248,11 @@ void ngx_http_cache_unlock(ngx_http_cach
 
 #if 0
 
-ngx_add_file_event(ngx_fd_t, ngx_event_handler_pt *handler, void *data)
+ngx_http_cache_add_file_event(ngx_http_cache_hash_t *hash,
+                              ngx_http_cache_t *cache)
 {
-    ngx_event_t  *ev;
+    ngx_event_t                 *ev;
+    ngx_http_cache_event_ctx_t  *ctx;
 
     ev = &ngx_cycle->read_events[fd];
     ngx_memzero(ev, sizeof(ngx_event_t);
@@ -250,7 +266,7 @@ ngx_add_file_event(ngx_fd_t, ngx_event_h
 
 void ngx_http_cache_invalidate(ngx_event_t *ev)
 {
-    ngx_http_cache_ctx_t  *ctx;
+    ngx_http_cache_event_ctx_t  *ctx;
 
     ctx = ev->data;
 
--- a/src/http/ngx_http_cache.h
+++ b/src/http/ngx_http_cache.h
@@ -101,6 +101,7 @@ ngx_http_cache_t *ngx_http_cache_alloc(n
                                        ngx_str_t *value, ngx_log_t *log);
 void ngx_http_cache_free(ngx_http_cache_t *cache,
                          ngx_str_t *key, ngx_str_t *value, ngx_log_t *log);
+void ngx_http_cache_lock(ngx_http_cache_hash_t *hash, ngx_http_cache_t *cache);
 void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash,
                            ngx_http_cache_t *cache, ngx_log_t *log);
 
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -176,6 +176,8 @@ ngx_log_debug(c->log, "NOPUSH");
                 hsize = 0;
             }
 
+            sent = 0;
+
             rc = sendfile(file->file->fd, c->fd, file->file_pos,
                           fsize + hsize, &hdtr, &sent, 0);