Fossil SCM
Optimizations to the ETag implementation.
Commit
2588d447839e1b44ef1408e0fd556a8bfefbfee8710abb8d8ecd52f81db9f34d
Parent
5b84cab0d6d0dd8…
1 file changed
+3
-2
+3
-2
| --- src/etag.c | ||
| +++ src/etag.c | ||
| @@ -129,10 +129,11 @@ | ||
| 129 | 129 | ** is checked, and if it contains a compatible ETag, then a |
| 130 | 130 | ** 304 Not Modified return is generated and execution aborts. This |
| 131 | 131 | ** routine does not return if the 304 is generated. |
| 132 | 132 | */ |
| 133 | 133 | void etag_require(int code){ |
| 134 | + if( (mEtag & code)==code ) return; | |
| 134 | 135 | mEtag |= code; |
| 135 | 136 | etag_check(); |
| 136 | 137 | } |
| 137 | 138 | void etag_require_hash(const char *zHash){ |
| 138 | 139 | if( zHash ){ |
| @@ -178,14 +179,14 @@ | ||
| 178 | 179 | ** The other elements are only present if the appropriate mask bits |
| 179 | 180 | ** appear in the first character. |
| 180 | 181 | */ |
| 181 | 182 | char *etag_generate(int m){ |
| 182 | 183 | Blob x = BLOB_INITIALIZER; |
| 183 | - int mtime; | |
| 184 | + static int mtime = 0; | |
| 184 | 185 | if( m<0 ) m = mEtag; |
| 185 | 186 | if( m & ETAG_DYNAMIC ) return 0; |
| 186 | - mtime = file_mtime(g.nameOfExe, ExtFILE); | |
| 187 | + if( mtime==0 ) mtime = file_mtime(g.nameOfExe, ExtFILE); | |
| 187 | 188 | blob_appendf(&x,"%d%x", m, mtime); |
| 188 | 189 | if( m & ETAG_HASH ){ |
| 189 | 190 | blob_appendf(&x, "/%s", zEHash); |
| 190 | 191 | }else if( m & ETAG_DATA ){ |
| 191 | 192 | int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom"); |
| 192 | 193 |
| --- src/etag.c | |
| +++ src/etag.c | |
| @@ -129,10 +129,11 @@ | |
| 129 | ** is checked, and if it contains a compatible ETag, then a |
| 130 | ** 304 Not Modified return is generated and execution aborts. This |
| 131 | ** routine does not return if the 304 is generated. |
| 132 | */ |
| 133 | void etag_require(int code){ |
| 134 | mEtag |= code; |
| 135 | etag_check(); |
| 136 | } |
| 137 | void etag_require_hash(const char *zHash){ |
| 138 | if( zHash ){ |
| @@ -178,14 +179,14 @@ | |
| 178 | ** The other elements are only present if the appropriate mask bits |
| 179 | ** appear in the first character. |
| 180 | */ |
| 181 | char *etag_generate(int m){ |
| 182 | Blob x = BLOB_INITIALIZER; |
| 183 | int mtime; |
| 184 | if( m<0 ) m = mEtag; |
| 185 | if( m & ETAG_DYNAMIC ) return 0; |
| 186 | mtime = file_mtime(g.nameOfExe, ExtFILE); |
| 187 | blob_appendf(&x,"%d%x", m, mtime); |
| 188 | if( m & ETAG_HASH ){ |
| 189 | blob_appendf(&x, "/%s", zEHash); |
| 190 | }else if( m & ETAG_DATA ){ |
| 191 | int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom"); |
| 192 |
| --- src/etag.c | |
| +++ src/etag.c | |
| @@ -129,10 +129,11 @@ | |
| 129 | ** is checked, and if it contains a compatible ETag, then a |
| 130 | ** 304 Not Modified return is generated and execution aborts. This |
| 131 | ** routine does not return if the 304 is generated. |
| 132 | */ |
| 133 | void etag_require(int code){ |
| 134 | if( (mEtag & code)==code ) return; |
| 135 | mEtag |= code; |
| 136 | etag_check(); |
| 137 | } |
| 138 | void etag_require_hash(const char *zHash){ |
| 139 | if( zHash ){ |
| @@ -178,14 +179,14 @@ | |
| 179 | ** The other elements are only present if the appropriate mask bits |
| 180 | ** appear in the first character. |
| 181 | */ |
| 182 | char *etag_generate(int m){ |
| 183 | Blob x = BLOB_INITIALIZER; |
| 184 | static int mtime = 0; |
| 185 | if( m<0 ) m = mEtag; |
| 186 | if( m & ETAG_DYNAMIC ) return 0; |
| 187 | if( mtime==0 ) mtime = file_mtime(g.nameOfExe, ExtFILE); |
| 188 | blob_appendf(&x,"%d%x", m, mtime); |
| 189 | if( m & ETAG_HASH ){ |
| 190 | blob_appendf(&x, "/%s", zEHash); |
| 191 | }else if( m & ETAG_DATA ){ |
| 192 | int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom"); |
| 193 |