ry / ebb fork watch download tarball
public this repo is viewable by everyone
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
use atoi_len instead of strncpy+atoi
Ryan Dahl (author)
2 months ago
commit  3aa982c4bbc1406747eb9a62f5385354b2f7e36b
tree    be1c0254ccc226d2b92f70a80e0c40f35c375baa
parent  bcdd79f30839a0ce14d377ec55337a6739b955d3
...
54
55
56
57
58
59
60
 
 
 
 
 
61
62
63
...
78
79
80
81
82
 
 
 
83
84
85
...
54
55
56
 
 
 
 
57
58
59
60
61
62
63
64
...
79
80
81
 
 
82
83
84
85
86
87
0
@@ -54,10 +54,11 @@ for quick and beautiful code, but for production web servers that might handle
0
 thousands of requests a second, an attempt should be made to be as efficient
0
 as possible in processing connections.
0
 
0
-Following are some benchmarks. Please take these measurements with a grain
0
-of salt. Benchmarks like these are notorious for presenting an inaccurate
0
-or highly slanted view of how software performs.
0
-The code for these can be found in the `benchmark` directory.
0
+Following are some benchmarks. Please take these measurements with a grain of
0
+salt. Benchmarks like these are notorious for presenting an inaccurate or
0
+highly slanted view of how software performs. These are tests using a very
0
+simple Rack applications, not with Ruby-on-Rails. The code for these can be
0
+found in the `benchmark` directory.
0
 
0
 ![Response Size](http://s3.amazonaws.com/four.livejournal/20080227/response_size.png)
0
 
0
@@ -78,8 +79,9 @@ buffer is set at 40 kilobytes before it writes to file.
0
 ## Contributions
0
 
0
 Contributions (patches, criticism, advice) are very welcome! The source code
0
-is hosted at [repo.or.cz](http://repo.or.cz/w/ebb.git). It can be retrieved
0
-by executing
0
+is hosted at [repo.or.cz](http://repo.or.cz/w/ebb.git) (and also mirrored at
0
+[github](http://github.com/ry/ebb/tree/master)). It can be retrieved by
0
+executing
0
 
0
 `git clone http://repo.or.cz/r/ebb.git`
0
 
...
111
112
113
 
 
 
 
 
 
 
114
115
116
117
118
119
120
121
122
123
124
 
125
126
127
...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
 
 
 
 
 
 
126
127
128
129
0
@@ -111,17 +111,19 @@ void http_version_cb(void *data, const char *at, size_t length)
0
   env_add_const(client, EBB_HTTP_VERSION, at, length);
0
 }
0
 
0
+int atoi_len(const char *str, int len)
0
+{
0
+ int i, mult, retr = 0;
0
+ for(mult=1, i=len-1; i>=0; i--, mult*=10)
0
+ retr += (str[i] - '0') * mult;
0
+ return retr;
0
+}
0
 
0
 void content_length_cb(void *data, const char *at, size_t length)
0
 {
0
   ebb_client *client = (ebb_client*)(data);
0
   env_add_const(client, EBB_CONTENT_LENGTH, at, length);
0
-
0
- /* i hate c. */
0
- char buf[20];
0
- strncpy(buf, at, length);
0
- buf[length] = '\0';
0
- client->content_length = atoi(buf);
0
+ client->content_length = atoi_len(at, length);
0
 }
0
 
0
 

Comments

    No one has commented yet.