Commits

Anonymous committed 3bc29ae

most problems solved. will be 0.9.0

Comments (0)

Files changed (7)

+2009-09-06  UENISHI Kota  <kuenishi@gmail.com>
+
+	* c_src/dispatcher.c (yatce_drv_control): most problems solves.
+	reason for memory leaking was here, not handling of hash_map
+	query failure. versioned as 0.9.0.
+
 2009-08-29  UENISHI Kota  <kuenishi@gmail.com>
 
 	* src/yatce.erl (start_link): timer:sleep/1 for waiting 

c_src/dispatcher.c

 #ifdef DEBUG_DONE
   fprintf(stderr, "%s %d: %s( %s ) - len: %d\n", __FILE__, __LINE__,  __func__, inspect_command( command ), len );
   if( len > 0 ){
-    ei_print_term(stderr, buf, &index);
-#  ifdef DEBUG_DONE
+    ei_print_term(stderr, buf, &index);     fprintf(stderr, "\n");
     DEBUG_INFO(buf, len);
-#  endif
-    fprintf(stderr, "\n");
     index = 0;
   }
 #endif
   //only uses table.
   if( (command & USE_TABLE) && !(command & USE_KEY) && !(command & USE_VALUE) ){
     table_name = read_table_name( buf, &index, len );    
-    //    table = (TCADB*)get_yatce_map(d, table_name);
     table = (TCADB*)get_hash_map(d, table_name);
     //case for YATCE_OPEN
     if( command == YATCE_OPEN ){
       if( table == NULL ){
 	table = tcadbnew();
-	//	if( ! push_yatce_map( d, table_name, (void*)table ) ){
+
 	if( ! push_hash_map( d, table_name, (void*)table ) ){
 	  fprintf(stderr, "%s %d: failed in putting TCADB '%s' into map.\n", __FILE__, __LINE__,  table_name ); 
 	}
 #ifdef DEBUG_DONE
     fprintf(stderr, "%s %d: %s( %s ) %s\n", __FILE__, __LINE__,  __func__, inspect_command( command ) , table_name);
 #endif
-    //    if(command == YATCE_CLOSE) pop_yatce_map(d, table_name);
+
     if(command == YATCE_CLOSE) pop_hash_map(d, table_name, NULL, NULL);
     rlen = table_operations(command, table, rbuf);
     driver_free(table_name);
       index = 0;
       *rbuf = encode_atom_pair_in_tuple_with_version(&index, "error", "badarith" );
       rlen = index;
-      return rlen;
     }
-    //    if( (table = (TCADB*)get_yatce_map(d, table_name) ) == NULL ){
-    if( (table = (TCADB*)get_hash_map(d, table_name) ) == NULL ){
+
+    else if( (table = (TCADB*)get_hash_map(d, table_name) ) == NULL ){
       index = 0;
       *rbuf = encode_atom_pair_in_tuple_with_version( &index, "error", "db_not_found" );
-      driver_free(table_name);
-      return index;
+      rlen = index;
     }
+    else {
 #ifdef DEBUG_DONE
-    printf( "%s %d: table name : %s\n", __FILE__, __LINE__, table_name );
-    printf( "%s %d: TCADB * adb = %p\n", __FILE__, __LINE__, table );
-    fprintf(stderr, "%s %d: %s( %s ) \n", __FILE__, __LINE__,  __func__, inspect_command( command ) );
+      printf( "%s %d: table name : %s\n", __FILE__, __LINE__, table_name );
+      printf( "%s %d: TCADB * adb = %p\n", __FILE__, __LINE__, table );
+      fprintf(stderr, "%s %d: %s( %s ) \n", __FILE__, __LINE__,  __func__, inspect_command( command ) );
 #endif
-    rlen = tc_key_operation(command, table, key, rbuf);
+      rlen = tc_key_operation(command, table, key, rbuf);
+    }
     driver_free(table_name);
     driver_free_binary(key);
     return rlen;
   }
+
   else if( (command & USE_TABLE) && (command & USE_KEY) && (command & USE_VALUE)){ //  YATCE_OUT, YATCE_GET, 
     r = decode_tuple3( &table_name, &key, &value, buf, &index);
 #ifdef DEBUG_DONE
       rlen = index;
       return rlen;
     }
-    //    if( (table = (TCADB*)get_yatce_map(d, table_name) ) == NULL ){
     if( (table = (TCADB*)get_hash_map(d, table_name) ) == NULL ){
       index = 0;
       *rbuf = encode_atom_pair_in_tuple_with_version( &index, "error", "db_not_found" );
-      driver_free(table_name);
-      return index;
-    };
+      rlen = index;
+    }else{
 #ifdef DEBUG_DONE
-    printf( "%s %d: table name = %s, TCADB * adb = %p\n", __FILE__, __LINE__, table_name, table );
-    fprintf(stderr, "%s %d: %s( %s ) \n", __FILE__, __LINE__,  __func__, inspect_command( command ) );
+      printf( "%s %d: table name = %s, TCADB * adb = %p\n", __FILE__, __LINE__, table_name, table );
+      fprintf(stderr, "%s %d: %s( %s ) \n", __FILE__, __LINE__,  __func__, inspect_command( command ) );
 #endif
-    switch(command) {
-    case YATCE_PUT: //{TableName, Key, Value}
-    case YATCE_PKEEP:
-      rlen = tc_put( table, key, value, rbuf, command );       break;
-      
-    case YATCE_PUTCAT:
-    case YATCE_ADDINT:
-    case YATCE_ADDDOUBLE:
-    default:
-      index = 0;
-      *rbuf = encode_atom_pair_in_tuple_with_version( &index, "error", "unsupported_operation" );
-      rlen = index;
+      switch(command) {
+      case YATCE_PUT: //{TableName, Key, Value}
+      case YATCE_PKEEP:
+	rlen = tc_put( table, key, value, rbuf, command );       break;
+	
+      case YATCE_PUTCAT:
+      case YATCE_ADDINT:
+      case YATCE_ADDDOUBLE:
+      default:
+	index = 0;
+	*rbuf = encode_atom_pair_in_tuple_with_version( &index, "error", "unsupported_operation" );
+	rlen = index;
+      }
     }
     driver_free(table_name);
     driver_free_binary(key);
     *table_namep = NULL;
     return -1;
   }
-#ifdef DEBUG_DONE
-  printf( "%s %d: table name : %s, %d\n", __FILE__, __LINE__, __func__, arity );
-#endif
+
   *table_namep = (char*)driver_alloc( sizeof(char) * MAXATOMLEN );
   if( ei_decode_atom(buf, index, *table_namep) != 0 ){
     return -1;
   }
-#ifdef DEBUG_DONE
-  printf( "%s %d: table name : %s\n", __FILE__, __LINE__, *table_namep );
-#endif
   
   *key = decode_key( buf, index );
   *value = decode_value( buf, index );
 // accoring to erlang-VM way; and return it.
 int get_binary_size(const char * buf){
   int i=0;
-  char * s = NULL;//driver_alloc(BUFSIZ);
+  ei_skip_term(buf, &i);
 
 #ifdef DEBUG_DONE
+  i=0;
   ei_print_term(stderr, buf, &i);
   fprintf(stderr, "\n");
-  i=0;
-#endif
-  ei_skip_term(buf, &i);
+  //  char * s = NULL;
   //  ei_s_print_term(&s, buf, &i);
-#ifdef DEBUG_DONE
   fprintf(stderr, "print:%s -size:%d\n", s, i);
 #endif
   return i;
   return decode_term( buf, index );
 }
 
-
 char * read_table_name( char * buf, int * index, int len ){
   char * table_name;
   int type, size;
     start('/tmp/test_sup.tch',256),
     gen_server:call(perf_controller, 
 		    {set_func, fun(T)->
-				       L=random:uniform(12),
+				       L=random:uniform(32),
 				       Key=generate(L),
-				       T:put(Key,generate(256))
-%				       T:get(Key)
+				       T:put(Key,generate(256)),
+				       T:get(Key)
 			       end }),
     gen_server:call(perf_controller, start).
 poll()->

test/perf_controller_SUITE.erl

 
 all()-> [start, stop].
 
-init_per_suite(Config) ->    Config.
-end_per_suite(Config) ->     Config.
+init_per_suite(Config) ->    
+    {ok,Pid}=gen_fsm:start({local, perf_timer}, perf_timer,1000,[]),
+    Config.
+end_per_suite(Config) -> 
+%%    ok=gen_fsm:send_event(perf_timer, stop),
+    Config.
 
 start(Config)-> 
     yatce:start([{libdir, "../../../c_src"}]),

test/yatce.coverspec

 
 %% Specific modules to include in cover.
 %% Mods = [atom()]
-{incl_mods, [tcadb, yatce]}.
+{incl_mods, [tcadb, yatce, perf_controller, perf_sup, perf_timer, unit_performer]}.
 
 %% Directories to exclude in cover.
 %{excl_dirs, Dirs}.
-YATCE_VSN = 0.8.5
+YATCE_VSN = 0.9.0