• R/O
  • SSH
  • HTTPS

globalbase: Commit


Commit MetaInfo

Revisão5870 (tree)
Hora2017-09-01 20:47:56
Autorjoshua

Mensagem de Log

gtItem etc.

Mudança Sumário

Diff

--- modules/tinyState/trunk/src/classes/gt/c++/co_gtItem.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/gt/c++/co_gtItem.cpp (revision 5870)
@@ -275,7 +275,11 @@
275275 return rDO|ACT_REPLAY;
276276 }
277277 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+*/
279283 REF_SET(this->read_content,0);
280284 REF_SET(this->read_buffer,0);
281285 if ( post_content == 0 ) {
--- modules/tinyState/trunk/src/classes/gt/c++/gtDataString.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/gt/c++/gtDataString.cpp (revision 5870)
@@ -231,9 +231,9 @@
231231 else return 0;
232232
233233 ptr ++;
234- target_ptr = ptr;
235234 ret = NEW gtDataString("");
236235 for ( ; ; ) {
236+ target_ptr = ptr;
237237 str = NEW stdString("");
238238 for ( ; *ptr && *ptr != '\\' && *ptr != term ; ptr ++ );
239239 len = ptr - target_ptr;
--- modules/tinyState/trunk/src/classes/ts/c++/co_tsRSAfileBase.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/ts/c++/co_tsRSAfileBase.cpp (revision 5870)
@@ -16,6 +16,7 @@
1616
1717
1818 #include "ts/c++/tsPipeIO.h"
19+#include "ts/c++/tsThread.h"
1920
2021 class TS_THISCLASS : public TS_BASECLASS {
2122 public:
@@ -95,9 +96,9 @@
9596 fd = fdopen(ret,"wb");
9697 return rDO|ACT_START;
9798 }
98-TS_STATE(ACT_FINISH)
99+TS_THREAD(ACT_FINISH)
99100 {
100- fclose(fd);
101+ soFCLOSE(fd);
101102 return rDO|ACT_FINISH_WAIT;
102103 }
103104 TS_STATE(ACT_FINISH_WAIT)
@@ -105,6 +106,7 @@
105106 if ( !pipe->is_complete() )
106107 return 0;
107108 REF_SET(error_stdString,pipe->error());
109+ REF_SET(result,pipe->recv());
108110 if ( error_stdString )
109111 return rDO|FIN_ERROR;
110112 if ( inp )
@@ -119,9 +121,13 @@
119121 result));
120122 return rDO|FIN_START;
121123 }
122-TS_STATE(FIN_ERROR)
124+TS_THREAD(FIN_ERROR)
123125 {
124- fclose(fd);
126+ soFCLOSE(fd);
127+ return rDO|FIN_ERROR_FINISH;
128+}
129+TS_STATE(FIN_ERROR_FINISH)
130+{
125131 parent->eventHandler(
126132 NEW stdEvent(
127133 TSE_RETURN,
--- modules/tinyState/trunk/src/classes/ts/c++/co_tsRSAread_PEM_privateKey.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/ts/c++/co_tsRSAread_PEM_privateKey.cpp (revision 5870)
@@ -29,13 +29,6 @@
2929 stdString * inp);
3030 private:
3131 protected:
32- stdRSA * rsa;
33- stdString * inp;
34- tsPipeIO * pipe;
35-
36- char * error_char;
37- stdString * error_stdString;
38- FILE * inpfd;
3932 };
4033
4134 TS_END_IMPLEMENT
--- modules/tinyState/trunk/src/classes/ts/c++/co_tsRSAread_PEM_publicKey.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/ts/c++/co_tsRSAread_PEM_publicKey.cpp (revision 5870)
@@ -29,13 +29,6 @@
2929 stdString * inp);
3030 private:
3131 protected:
32- stdRSA * rsa;
33- stdString * inp;
34- tsPipeIO * pipe;
35-
36- char * error_char;
37- stdString * error_stdString;
38- FILE * inpfd;
3932 };
4033
4134 TS_END_IMPLEMENT
--- modules/tinyState/trunk/src/classes/ts/c++/sObject.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/ts/c++/sObject.cpp (revision 5870)
@@ -217,6 +217,7 @@
217217 operator new[](size_t cbSize,const char * __file,int __line)
218218 throw(std::bad_alloc)
219219 {
220+ // ::printf("new[] %lu %s %i\n",cbSize,__file,__line);
220221 MEM_HEADER * mem = (MEM_HEADER*)malloc(cbSize+sizeof(MEM_HEADER));
221222 mem->size = cbSize;
222223 mem->cp = get_cp(__file,__line,ref_subline,cp_hash_mem);
@@ -225,7 +226,6 @@
225226 insert_active_list(mem);
226227 mem ++;
227228 memset(mem,0,cbSize);
228-//printf("new[] %p %lu %s %i\n",mem,cbSize,__file,__line);
229229 return mem;
230230 }
231231
@@ -348,6 +348,30 @@
348348 return 0;
349349 }
350350 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
351375 sObject::__pipe(const char *filename,int line,int pipefd[2])
352376 {
353377 int ret;
--- modules/tinyState/trunk/src/classes/ts/c++/stdEvent.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/ts/c++/stdEvent.cpp (revision 5870)
@@ -6,8 +6,8 @@
66
77 stdEvent::~stdEvent()
88 {
9+ REF_SET(this->msg_obj,0);
910 REF_SET(this->source,0);
10- REF_SET(this->msg_obj,0);
1111 }
1212
1313 stdEvent::stdEvent(
--- modules/tinyState/trunk/src/classes/ts/c++/stdQueue.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/ts/c++/stdQueue.cpp (revision 5870)
@@ -3,8 +3,9 @@
33 #include "ts/c++/stdQueue.h"
44 #include "ts/c++/stdEvent.h"
55
6+int
7+stdQueueDebug::debug_flag = 0;
68
7-
89 void object_test(void * _ptr)
910 {
1011 stdQueueElement<stdEvent>* ptr = (stdQueueElement<stdEvent>*)_ptr;
--- modules/tinyState/trunk/src/classes/ts/c++/stdQueueString.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/ts/c++/stdQueueString.cpp (revision 5870)
@@ -2,6 +2,14 @@
22
33 #include "ts/c++/stdQueueString.h"
44
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+
513 stdQueueString *
614 stdQueueString::filter(stdArray<stdString*> * flt)
715 {
@@ -113,7 +121,7 @@
113121 }
114122 else if ( r > 0 ) {
115123 ret->ins(MAX_INTEGER64,elp2->data);
116- elp1 = elp2->next;
124+ elp2 = elp2->next;
117125 }
118126 else {
119127 ret->ins(MAX_INTEGER64,elp1->data);
@@ -121,6 +129,10 @@
121129 elp2 = elp2->next;
122130 }
123131 }
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);
124136 return ret;
125137 }
126138
@@ -141,7 +153,7 @@
141153 elp1 = elp1->next;
142154 }
143155 else if ( r > 0 ) {
144- elp1 = elp2->next;
156+ elp2 = elp2->next;
145157 }
146158 else {
147159 elp1 = elp1->next;
@@ -148,6 +160,8 @@
148160 elp2 = elp2->next;
149161 }
150162 }
163+ for ( ; elp1 ; elp1 = elp1->next )
164+ ret->ins(MAX_INTEGER64,elp1->data);
151165 return ret;
152166 }
153167
@@ -155,7 +169,7 @@
155169 stdQueueString::add(
156170 stdQueue<stdString> * a2)
157171 {
158- return add(dynamic_cast<stdQueueString*>(a2));
172+ return add(NEW stdQueueString(a2));
159173 }
160174
161175 stdQueueString *
@@ -162,5 +176,5 @@
162176 stdQueueString::sub(
163177 stdQueue<stdString> * a2)
164178 {
165- return sub(dynamic_cast<stdQueueString*>(a2));
179+ return sub(NEW stdQueueString(a2));
166180 }
--- modules/tinyState/trunk/src/classes/ts/c++/tsPipeIO.cpp (revision 5869)
+++ modules/tinyState/trunk/src/classes/ts/c++/tsPipeIO.cpp (revision 5870)
@@ -79,7 +79,7 @@
7979 REF_SET(error_msg,NEW stdString("already running"));
8080 return -1;
8181 }
82- if ( pipe(p) < 0 ) {
82+ if ( soPIPE(p) < 0 ) {
8383 REF_SET(error_msg,NEW stdString(
8484 strerror(errno)));
8585 return -1;
@@ -129,6 +129,8 @@
129129
130130 TS_STATE(INI_START)
131131 {
132+ if ( destroy_flag || ref_destroy_flag )
133+ return rDO|FIN_START;
132134 if ( start_flag == 0 )
133135 return 0;
134136 if ( inp )
@@ -150,11 +152,8 @@
150152 {
151153 stdString * ret;
152154 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 )
156156 return rDO|ACT_FINISH;
157- }
158157 REF_SET(result,STR_NULL(result)->add(ret));
159158 return rDO|ACT_READ_LINE;
160159 }
@@ -187,14 +186,14 @@
187186 return rDO|ACT_WRITE_STRING_LOOP;
188187 }
189188
190-TS_THREAD(ACT_FINISH)
189+TS_STATE(ACT_FINISH)
191190 {
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);
198197 complete_flag = 1;
199198 parent->wakeup();
200199 return rDO|ACT_FINISH_RET;
--- modules/tinyState/trunk/src/h/gt/c++/gtType.h (revision 5869)
+++ modules/tinyState/trunk/src/h/gt/c++/gtType.h (revision 5870)
@@ -30,6 +30,7 @@
3030 gtc##__type(); \
3131 gtc##__type(gtType * base,gtData * inp); \
3232 gtc##__type(gtType * base,__type * inp); \
33+ gtc##__type(gtType * base); \
3334 ~gtc##__type(); \
3435 virtual gtc##__type * gtt_copy(); \
3536 virtual int gtt_compare(gtc##__type * inp); \
@@ -52,6 +53,9 @@
5253 gtc##__type::gtc##__type(gtType * base,__type * inp) { \
5354 gtt_##__type::copy(base,&d,inp); \
5455 } \
56+gtc##__type::gtc##__type(gtType * base) { \
57+ gtt_##__type::initial_node(base,&d); \
58+} \
5559 gtc##__type::~gtc##__type() { \
5660 destroy(); \
5761 } \
--- modules/tinyState/trunk/src/h/ts/c++/sObject.h (revision 5869)
+++ modules/tinyState/trunk/src/h/ts/c++/sObject.h (revision 5870)
@@ -34,6 +34,7 @@
3434
3535 static int __open(const char *,int,const char *,int,mode_t);
3636 static int __close(int);
37+ static int __fclose(FILE*);
3738 static int __pipe(const char *,int,int *);
3839 static int __socket(const char *,int,int,int,int);
3940 static int __accept(const char *,int,int,struct sockaddr *,socklen_t *);
@@ -53,6 +54,7 @@
5354 #define soSOCKET(x,y,z) sObject::__socket(__FILE__,__LINE__,x,y,z)
5455 #define soACCEPT(x,y,z) sObject::__accept(__FILE__,__LINE__,x,y,z)
5556 #define soOPENPTY(x,y,z,a,b) sObject::__openpty(__FILE__,__LINE__,x,y,z,a,b)
57+#define soFCLOSE(x) sObject::__fclose(x)
5658
5759 void * operator new[](size_t cbSize,const char * __file,int __line)
5860 throw(std::bad_alloc);
--- modules/tinyState/trunk/src/h/ts/c++/stdQueue.h (revision 5869)
+++ modules/tinyState/trunk/src/h/ts/c++/stdQueue.h (revision 5870)
@@ -7,6 +7,11 @@
77 #include "ts/c++/ts_types.h"
88 #include "ts/c++/stdObject.h"
99
10+class stdQueueDebug {
11+public:
12+ static int debug_flag;
13+};
14+
1015 template<class __TYPE>
1116 class stdQueue_;
1217
@@ -247,15 +252,18 @@
247252 }
248253 count = 1;
249254 for ( el = head ; el->next ; el = el->next , count ++ )
250- break;
255+ ;
251256 REF_SET(tail,el);
252257 }
253258
259+
260+
254261 stdQueueElement<__TYPE> *
255262 _sort(stdQueueElement<__TYPE> * inp,int (*cmp)(__TYPE*,__TYPE*))
256263 {
257264 stdQueueElement<__TYPE> * a, * b, * ret,* _ret, ** rp;
258265 int conv;
266+
259267 if ( inp == 0 || inp->next == 0 )
260268 return inp;
261269 _ret = 0;
@@ -378,8 +386,6 @@
378386 q->check(this,copy_stdQueue);
379387 }
380388
381-
382-
383389 static int
384390 cmp_stdQueue2(__TYPE * d1,stdObject * d2)
385391 {
--- modules/tinyState/trunk/src/h/ts/c++/stdQueueString.h (revision 5869)
+++ modules/tinyState/trunk/src/h/ts/c++/stdQueueString.h (revision 5870)
@@ -11,11 +11,7 @@
1111 public:
1212 stdQueueString() {
1313 }
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);
1915 ~stdQueueString() {
2016 }
2117 stdQueueString *
@@ -22,8 +18,17 @@
2218 filter(stdArray<stdString*> * flt);
2319
2420 static int cmp(stdString * s1,stdString * s2) {
21+ if ( s2 == 0 ) {
22+ ::printf("%s",s1->get_str());
23+ return 0;
24+ }
2525 return STR_NULL(s1)->cmp(s2);
2626 }
27+ static int cmp_del(stdString * s1,stdString * s2) {
28+ if ( STR_NULL(s1)->cmp(s2) == 0 )
29+ return 1;
30+ return 0;
31+ }
2732
2833 stdQueueString * add(
2934 stdQueueString *);
--- modules/tinyState/trunk/src/scripts/gt/gtItem.js (revision 5869)
+++ modules/tinyState/trunk/src/scripts/gt/gtItem.js (revision 5870)
@@ -261,6 +261,7 @@
261261 *=====================================================*/
262262
263263 INI_TINYSTATE_START : function(ev) {
264+ this.i_writeResultQueue = [];
264265 var prev = this.i_prevGtItem;
265266 if ( !prev )
266267 return "doINI_gtItem_GET";
@@ -406,7 +407,6 @@
406407 },
407408
408409 ACT_gtItem_WRITE : function(ev) {
409- this.i_writeResultQueue = [];
410410 this.i_temp = this.i_data;
411411 //this.dump("ORG = "+JSON.stringify(this.i_data));
412412 for ( ; ; ) {
@@ -511,6 +511,14 @@
511511 },
512512
513513 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+
514522 if ( this.i_transaction )
515523 this.i_transactionOut();
516524 this.i_submit = false;
Show on old repository browser