ry / ebb fork watch download tarball
public
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
Search Repo:
Merge branch 'vanilla'
gnosek (author)
Mon Mar 24 06:59:25 -0700 2008
commit  878886119da115761ac0f497122d7d207929fe8d
tree    b10733afc52b868023a91af86ba3c12927395967
parent  c1567cb931b353f65b61beeef6bb413d1c88c280 parent  f278ac2badf0c6e3a8f7c2572217cd38e7780f44
...
120
121
122
123
124
 
125
126
127
...
133
134
135
136
137
138
 
 
 
 
 
 
 
 
 
 
 
 
139
140
141
...
343
344
345
 
346
347
348
349
...
549
550
551
552
 
553
554
 
 
555
556
557
...
120
121
122
 
123
124
125
126
127
...
133
134
135
 
 
 
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
352
353
354
355
356
357
358
359
...
559
560
561
 
562
563
564
565
566
567
568
569
0
@@ -120,8 +120,8 @@
0
 static void* read_body_into_file(void *_client)
0
 {
0
   ebb_client *client = (ebb_client*)_client;
0
- static unsigned int id;
0
   FILE *tmpfile;
0
+ char *filename = "/tmp/.ebb_upload.XXXXXX";
0
   
0
   assert(client->open);
0
   assert(client->server->open);
0
@@ -133,9 +133,18 @@
0
   int ret = fcntl(client->fd, F_SETFL, flags & ~O_NONBLOCK);
0
   assert(0 <= ret);
0
   
0
- sprintf(client->upload_filename, "/tmp/ebb_upload_%010d", id++);
0
- tmpfile = fopen(client->upload_filename, "w+");
0
- if(tmpfile == NULL) g_message("Cannot open tmpfile %s", client->upload_filename);
0
+ if(0 > mkstemp(filename)) {
0
+ perror("mkstemp()");
0
+ ebb_client_close(client);
0
+ return NULL;
0
+ }
0
+ client->upload_filename = strdup(filename);
0
+ tmpfile = fopen(filename, "w+");
0
+ if(tmpfile == NULL) {
0
+ perror("opening tempfile for uplaod");
0
+ ebb_client_close(client);
0
+ return NULL;
0
+ }
0
   client->upload_file = tmpfile;
0
   
0
   size_t body_head_length = client->read - client->parser.nread;
0
@@ -343,6 +352,7 @@
0
    * because the backend is going to keep sending such long requests.
0
    */
0
   client->response_buffer->len = 0;
0
+ client->upload_filename = NULL;
0
   
0
   /* SETUP READ AND TIMEOUT WATCHERS */
0
   client->write_watcher.data = client;
0
0
@@ -549,9 +559,11 @@
0
     ev_io_stop(client->server->loop, &client->write_watcher);
0
     ev_timer_stop(client->server->loop, &client->timeout_watcher);
0
     
0
- if(client->upload_filee) {
0
+ if(client->upload_filename) {
0
       fclose(client->upload_file);
0
       unlink(client->upload_filename);
0
+ client->upload_file = NULL;
0
+ client->upload_filename = NULL;
0
     }
0
     
0
     close(client->fd);
...
52
53
54
55
 
56
57
58
...
52
53
54
 
55
56
57
58
0
@@ -52,7 +52,7 @@
0
   ev_io read_watcher;
0
   size_t read, nread_from_body;
0
   
0
- char upload_filename[200];
0
+ char *upload_filename;
0
   FILE *upload_file;
0
   
0
   ev_io write_watcher;

Comments

    No one has commented yet.