gtItem etc.
@@ -275,7 +275,11 @@ | ||
275 | 275 | return rDO|ACT_REPLAY; |
276 | 276 | } |
277 | 277 | REF_SET(post_content, gtData::json_parse(this->read_content)); |
278 | -//printf("READ_CONTENT %p %s\n",this->parent,this->read_content->get_str()); | |
278 | +/* | |
279 | +::printf("READ_CONTENT %p %s\n",this->parent,this->read_content->get_str()); | |
280 | +::printf("R %s\n",GT_NULL(post_content->get("[\"data\",\"private-key\"]"))->get_str()); | |
281 | +::printf("POST CONTENT %s\n",post_content->json()->get_str()); | |
282 | +*/ | |
279 | 283 | REF_SET(this->read_content,0); |
280 | 284 | REF_SET(this->read_buffer,0); |
281 | 285 | if ( post_content == 0 ) { |
@@ -231,9 +231,9 @@ | ||
231 | 231 | else return 0; |
232 | 232 | |
233 | 233 | ptr ++; |
234 | - target_ptr = ptr; | |
235 | 234 | ret = NEW gtDataString(""); |
236 | 235 | for ( ; ; ) { |
236 | + target_ptr = ptr; | |
237 | 237 | str = NEW stdString(""); |
238 | 238 | for ( ; *ptr && *ptr != '\\' && *ptr != term ; ptr ++ ); |
239 | 239 | len = ptr - target_ptr; |
@@ -16,6 +16,7 @@ | ||
16 | 16 | |
17 | 17 | |
18 | 18 | #include "ts/c++/tsPipeIO.h" |
19 | +#include "ts/c++/tsThread.h" | |
19 | 20 | |
20 | 21 | class TS_THISCLASS : public TS_BASECLASS { |
21 | 22 | public: |
@@ -95,9 +96,9 @@ | ||
95 | 96 | fd = fdopen(ret,"wb"); |
96 | 97 | return rDO|ACT_START; |
97 | 98 | } |
98 | -TS_STATE(ACT_FINISH) | |
99 | +TS_THREAD(ACT_FINISH) | |
99 | 100 | { |
100 | - fclose(fd); | |
101 | + soFCLOSE(fd); | |
101 | 102 | return rDO|ACT_FINISH_WAIT; |
102 | 103 | } |
103 | 104 | TS_STATE(ACT_FINISH_WAIT) |
@@ -105,6 +106,7 @@ | ||
105 | 106 | if ( !pipe->is_complete() ) |
106 | 107 | return 0; |
107 | 108 | REF_SET(error_stdString,pipe->error()); |
109 | + REF_SET(result,pipe->recv()); | |
108 | 110 | if ( error_stdString ) |
109 | 111 | return rDO|FIN_ERROR; |
110 | 112 | if ( inp ) |
@@ -119,9 +121,13 @@ | ||
119 | 121 | result)); |
120 | 122 | return rDO|FIN_START; |
121 | 123 | } |
122 | -TS_STATE(FIN_ERROR) | |
124 | +TS_THREAD(FIN_ERROR) | |
123 | 125 | { |
124 | - fclose(fd); | |
126 | + soFCLOSE(fd); | |
127 | + return rDO|FIN_ERROR_FINISH; | |
128 | +} | |
129 | +TS_STATE(FIN_ERROR_FINISH) | |
130 | +{ | |
125 | 131 | parent->eventHandler( |
126 | 132 | NEW stdEvent( |
127 | 133 | TSE_RETURN, |
@@ -29,13 +29,6 @@ | ||
29 | 29 | stdString * inp); |
30 | 30 | private: |
31 | 31 | protected: |
32 | - stdRSA * rsa; | |
33 | - stdString * inp; | |
34 | - tsPipeIO * pipe; | |
35 | - | |
36 | - char * error_char; | |
37 | - stdString * error_stdString; | |
38 | - FILE * inpfd; | |
39 | 32 | }; |
40 | 33 | |
41 | 34 | TS_END_IMPLEMENT |
@@ -29,13 +29,6 @@ | ||
29 | 29 | stdString * inp); |
30 | 30 | private: |
31 | 31 | protected: |
32 | - stdRSA * rsa; | |
33 | - stdString * inp; | |
34 | - tsPipeIO * pipe; | |
35 | - | |
36 | - char * error_char; | |
37 | - stdString * error_stdString; | |
38 | - FILE * inpfd; | |
39 | 32 | }; |
40 | 33 | |
41 | 34 | TS_END_IMPLEMENT |
@@ -217,6 +217,7 @@ | ||
217 | 217 | operator new[](size_t cbSize,const char * __file,int __line) |
218 | 218 | throw(std::bad_alloc) |
219 | 219 | { |
220 | + // ::printf("new[] %lu %s %i\n",cbSize,__file,__line); | |
220 | 221 | MEM_HEADER * mem = (MEM_HEADER*)malloc(cbSize+sizeof(MEM_HEADER)); |
221 | 222 | mem->size = cbSize; |
222 | 223 | mem->cp = get_cp(__file,__line,ref_subline,cp_hash_mem); |
@@ -225,7 +226,6 @@ | ||
225 | 226 | insert_active_list(mem); |
226 | 227 | mem ++; |
227 | 228 | memset(mem,0,cbSize); |
228 | -//printf("new[] %p %lu %s %i\n",mem,cbSize,__file,__line); | |
229 | 229 | return mem; |
230 | 230 | } |
231 | 231 |
@@ -348,6 +348,30 @@ | ||
348 | 348 | return 0; |
349 | 349 | } |
350 | 350 | int |
351 | +sObject::__fclose(FILE * fd) | |
352 | +{ | |
353 | +int er; | |
354 | +const char * file; | |
355 | +int line; | |
356 | +int s; | |
357 | + s = fileno(fd); | |
358 | + if ( descriptor_list[s] == 0 ) | |
359 | + stdObject::panic("close not opened fd"); | |
360 | + file = descriptor_list[s]->filename; | |
361 | + line = descriptor_list[s]->line; | |
362 | + flush_open_hash(s); | |
363 | + for ( ; ; ) { | |
364 | + er = fclose(fd); | |
365 | + if ( er == 0 ) | |
366 | + break; | |
367 | + if ( errno == EINTR ) | |
368 | + continue; | |
369 | + set_open_hash(s,file,line); | |
370 | + return er; | |
371 | + } | |
372 | + return 0; | |
373 | +} | |
374 | +int | |
351 | 375 | sObject::__pipe(const char *filename,int line,int pipefd[2]) |
352 | 376 | { |
353 | 377 | int ret; |
@@ -6,8 +6,8 @@ | ||
6 | 6 | |
7 | 7 | stdEvent::~stdEvent() |
8 | 8 | { |
9 | + REF_SET(this->msg_obj,0); | |
9 | 10 | REF_SET(this->source,0); |
10 | - REF_SET(this->msg_obj,0); | |
11 | 11 | } |
12 | 12 | |
13 | 13 | stdEvent::stdEvent( |
@@ -3,8 +3,9 @@ | ||
3 | 3 | #include "ts/c++/stdQueue.h" |
4 | 4 | #include "ts/c++/stdEvent.h" |
5 | 5 | |
6 | +int | |
7 | +stdQueueDebug::debug_flag = 0; | |
6 | 8 | |
7 | - | |
8 | 9 | void object_test(void * _ptr) |
9 | 10 | { |
10 | 11 | stdQueueElement<stdEvent>* ptr = (stdQueueElement<stdEvent>*)_ptr; |
@@ -2,6 +2,14 @@ | ||
2 | 2 | |
3 | 3 | #include "ts/c++/stdQueueString.h" |
4 | 4 | |
5 | +stdQueueString::stdQueueString(stdQueue<stdString> * str) | |
6 | +{ | |
7 | + str = NEW stdQueue<stdString>(str); | |
8 | + REF_SET(head,str->head); | |
9 | + REF_SET(tail,str->head); | |
10 | + count = str->count; | |
11 | +} | |
12 | + | |
5 | 13 | stdQueueString * |
6 | 14 | stdQueueString::filter(stdArray<stdString*> * flt) |
7 | 15 | { |
@@ -113,7 +121,7 @@ | ||
113 | 121 | } |
114 | 122 | else if ( r > 0 ) { |
115 | 123 | ret->ins(MAX_INTEGER64,elp2->data); |
116 | - elp1 = elp2->next; | |
124 | + elp2 = elp2->next; | |
117 | 125 | } |
118 | 126 | else { |
119 | 127 | ret->ins(MAX_INTEGER64,elp1->data); |
@@ -121,6 +129,10 @@ | ||
121 | 129 | elp2 = elp2->next; |
122 | 130 | } |
123 | 131 | } |
132 | + for ( ; elp1 ; elp1 = elp1->next ) | |
133 | + ret->ins(MAX_INTEGER64,elp1->data); | |
134 | + for ( ; elp2 ; elp2 = elp2->next ) | |
135 | + ret->ins(MAX_INTEGER64,elp1->data); | |
124 | 136 | return ret; |
125 | 137 | } |
126 | 138 |
@@ -141,7 +153,7 @@ | ||
141 | 153 | elp1 = elp1->next; |
142 | 154 | } |
143 | 155 | else if ( r > 0 ) { |
144 | - elp1 = elp2->next; | |
156 | + elp2 = elp2->next; | |
145 | 157 | } |
146 | 158 | else { |
147 | 159 | elp1 = elp1->next; |
@@ -148,6 +160,8 @@ | ||
148 | 160 | elp2 = elp2->next; |
149 | 161 | } |
150 | 162 | } |
163 | + for ( ; elp1 ; elp1 = elp1->next ) | |
164 | + ret->ins(MAX_INTEGER64,elp1->data); | |
151 | 165 | return ret; |
152 | 166 | } |
153 | 167 |
@@ -155,7 +169,7 @@ | ||
155 | 169 | stdQueueString::add( |
156 | 170 | stdQueue<stdString> * a2) |
157 | 171 | { |
158 | - return add(dynamic_cast<stdQueueString*>(a2)); | |
172 | + return add(NEW stdQueueString(a2)); | |
159 | 173 | } |
160 | 174 | |
161 | 175 | stdQueueString * |
@@ -162,5 +176,5 @@ | ||
162 | 176 | stdQueueString::sub( |
163 | 177 | stdQueue<stdString> * a2) |
164 | 178 | { |
165 | - return sub(dynamic_cast<stdQueueString*>(a2)); | |
179 | + return sub(NEW stdQueueString(a2)); | |
166 | 180 | } |
@@ -79,7 +79,7 @@ | ||
79 | 79 | REF_SET(error_msg,NEW stdString("already running")); |
80 | 80 | return -1; |
81 | 81 | } |
82 | - if ( pipe(p) < 0 ) { | |
82 | + if ( soPIPE(p) < 0 ) { | |
83 | 83 | REF_SET(error_msg,NEW stdString( |
84 | 84 | strerror(errno))); |
85 | 85 | return -1; |
@@ -129,6 +129,8 @@ | ||
129 | 129 | |
130 | 130 | TS_STATE(INI_START) |
131 | 131 | { |
132 | + if ( destroy_flag || ref_destroy_flag ) | |
133 | + return rDO|FIN_START; | |
132 | 134 | if ( start_flag == 0 ) |
133 | 135 | return 0; |
134 | 136 | if ( inp ) |
@@ -150,11 +152,8 @@ | ||
150 | 152 | { |
151 | 153 | stdString * ret; |
152 | 154 | R_SET(ret); |
153 | - if ( STR_NULL(ret)->cmp("") == 0 ) { | |
154 | - ior->destroy(); | |
155 | - REF_SET(ior,0); | |
155 | + if ( STR_NULL(ret)->cmp("") == 0 ) | |
156 | 156 | return rDO|ACT_FINISH; |
157 | - } | |
158 | 157 | REF_SET(result,STR_NULL(result)->add(ret)); |
159 | 158 | return rDO|ACT_READ_LINE; |
160 | 159 | } |
@@ -187,14 +186,14 @@ | ||
187 | 186 | return rDO|ACT_WRITE_STRING_LOOP; |
188 | 187 | } |
189 | 188 | |
190 | -TS_THREAD(ACT_FINISH) | |
189 | +TS_STATE(ACT_FINISH) | |
191 | 190 | { |
192 | - soCLOSE(p[0]); | |
193 | - soCLOSE(p[1]); | |
194 | - return rDO|ACT_FINISH_2; | |
195 | -} | |
196 | -TS_STATE(ACT_FINISH_2) | |
197 | -{ | |
191 | + if ( iow ) | |
192 | + iow->destroy(); | |
193 | + if ( ior ) | |
194 | + ior->destroy(); | |
195 | + REF_SET(iow,0); | |
196 | + REF_SET(ior,0); | |
198 | 197 | complete_flag = 1; |
199 | 198 | parent->wakeup(); |
200 | 199 | return rDO|ACT_FINISH_RET; |
@@ -30,6 +30,7 @@ | ||
30 | 30 | gtc##__type(); \ |
31 | 31 | gtc##__type(gtType * base,gtData * inp); \ |
32 | 32 | gtc##__type(gtType * base,__type * inp); \ |
33 | + gtc##__type(gtType * base); \ | |
33 | 34 | ~gtc##__type(); \ |
34 | 35 | virtual gtc##__type * gtt_copy(); \ |
35 | 36 | virtual int gtt_compare(gtc##__type * inp); \ |
@@ -52,6 +53,9 @@ | ||
52 | 53 | gtc##__type::gtc##__type(gtType * base,__type * inp) { \ |
53 | 54 | gtt_##__type::copy(base,&d,inp); \ |
54 | 55 | } \ |
56 | +gtc##__type::gtc##__type(gtType * base) { \ | |
57 | + gtt_##__type::initial_node(base,&d); \ | |
58 | +} \ | |
55 | 59 | gtc##__type::~gtc##__type() { \ |
56 | 60 | destroy(); \ |
57 | 61 | } \ |
@@ -34,6 +34,7 @@ | ||
34 | 34 | |
35 | 35 | static int __open(const char *,int,const char *,int,mode_t); |
36 | 36 | static int __close(int); |
37 | + static int __fclose(FILE*); | |
37 | 38 | static int __pipe(const char *,int,int *); |
38 | 39 | static int __socket(const char *,int,int,int,int); |
39 | 40 | static int __accept(const char *,int,int,struct sockaddr *,socklen_t *); |
@@ -53,6 +54,7 @@ | ||
53 | 54 | #define soSOCKET(x,y,z) sObject::__socket(__FILE__,__LINE__,x,y,z) |
54 | 55 | #define soACCEPT(x,y,z) sObject::__accept(__FILE__,__LINE__,x,y,z) |
55 | 56 | #define soOPENPTY(x,y,z,a,b) sObject::__openpty(__FILE__,__LINE__,x,y,z,a,b) |
57 | +#define soFCLOSE(x) sObject::__fclose(x) | |
56 | 58 | |
57 | 59 | void * operator new[](size_t cbSize,const char * __file,int __line) |
58 | 60 | throw(std::bad_alloc); |
@@ -7,6 +7,11 @@ | ||
7 | 7 | #include "ts/c++/ts_types.h" |
8 | 8 | #include "ts/c++/stdObject.h" |
9 | 9 | |
10 | +class stdQueueDebug { | |
11 | +public: | |
12 | + static int debug_flag; | |
13 | +}; | |
14 | + | |
10 | 15 | template<class __TYPE> |
11 | 16 | class stdQueue_; |
12 | 17 |
@@ -247,15 +252,18 @@ | ||
247 | 252 | } |
248 | 253 | count = 1; |
249 | 254 | for ( el = head ; el->next ; el = el->next , count ++ ) |
250 | - break; | |
255 | + ; | |
251 | 256 | REF_SET(tail,el); |
252 | 257 | } |
253 | 258 | |
259 | + | |
260 | + | |
254 | 261 | stdQueueElement<__TYPE> * |
255 | 262 | _sort(stdQueueElement<__TYPE> * inp,int (*cmp)(__TYPE*,__TYPE*)) |
256 | 263 | { |
257 | 264 | stdQueueElement<__TYPE> * a, * b, * ret,* _ret, ** rp; |
258 | 265 | int conv; |
266 | + | |
259 | 267 | if ( inp == 0 || inp->next == 0 ) |
260 | 268 | return inp; |
261 | 269 | _ret = 0; |
@@ -378,8 +386,6 @@ | ||
378 | 386 | q->check(this,copy_stdQueue); |
379 | 387 | } |
380 | 388 | |
381 | - | |
382 | - | |
383 | 389 | static int |
384 | 390 | cmp_stdQueue2(__TYPE * d1,stdObject * d2) |
385 | 391 | { |
@@ -11,11 +11,7 @@ | ||
11 | 11 | public: |
12 | 12 | stdQueueString() { |
13 | 13 | } |
14 | - stdQueueString(stdQueue<stdString>* str) { | |
15 | - str = NEW stdQueue<stdString>(str); | |
16 | - REF_SET(head,str->head); | |
17 | - REF_SET(tail,str->head); | |
18 | - } | |
14 | + stdQueueString(stdQueue<stdString>* str); | |
19 | 15 | ~stdQueueString() { |
20 | 16 | } |
21 | 17 | stdQueueString * |
@@ -22,8 +18,17 @@ | ||
22 | 18 | filter(stdArray<stdString*> * flt); |
23 | 19 | |
24 | 20 | static int cmp(stdString * s1,stdString * s2) { |
21 | + if ( s2 == 0 ) { | |
22 | + ::printf("%s",s1->get_str()); | |
23 | + return 0; | |
24 | + } | |
25 | 25 | return STR_NULL(s1)->cmp(s2); |
26 | 26 | } |
27 | + static int cmp_del(stdString * s1,stdString * s2) { | |
28 | + if ( STR_NULL(s1)->cmp(s2) == 0 ) | |
29 | + return 1; | |
30 | + return 0; | |
31 | + } | |
27 | 32 | |
28 | 33 | stdQueueString * add( |
29 | 34 | stdQueueString *); |
@@ -261,6 +261,7 @@ | ||
261 | 261 | *=====================================================*/ |
262 | 262 | |
263 | 263 | INI_TINYSTATE_START : function(ev) { |
264 | + this.i_writeResultQueue = []; | |
264 | 265 | var prev = this.i_prevGtItem; |
265 | 266 | if ( !prev ) |
266 | 267 | return "doINI_gtItem_GET"; |
@@ -406,7 +407,6 @@ | ||
406 | 407 | }, |
407 | 408 | |
408 | 409 | ACT_gtItem_WRITE : function(ev) { |
409 | - this.i_writeResultQueue = []; | |
410 | 410 | this.i_temp = this.i_data; |
411 | 411 | //this.dump("ORG = "+JSON.stringify(this.i_data)); |
412 | 412 | for ( ; ; ) { |
@@ -511,6 +511,14 @@ | ||
511 | 511 | }, |
512 | 512 | |
513 | 513 | FIN_START : function(ev) { |
514 | + for ( ; ; ) { | |
515 | + var req = this.i_writeQueue.shift(); | |
516 | + if ( !req ) | |
517 | + break; | |
518 | + this.i_writeResultQueue.push(req); | |
519 | + } | |
520 | + this.i_sendWriteResult("error",404); | |
521 | + | |
514 | 522 | if ( this.i_transaction ) |
515 | 523 | this.i_transactionOut(); |
516 | 524 | this.i_submit = false; |