Ver código fonte

leak fix + minor code changes

* if rules.scm file didn't exist, failure branch didn't "deinit" the
  scheme file
* trying to supress some valgrind errors with other init values
* unloading rules at end (still trying to make valgrind happy)
clementinecomputing 6 anos atrás
pai
commit
80e735d250
2 arquivos alterados com 12 adições e 3 exclusões
  1. 5 0
      busunit/passdb/pass_communication.c
  2. 7 3
      busunit/passdb/passdb.c

+ 5 - 0
busunit/passdb/pass_communication.c

@@ -370,6 +370,8 @@ int handle_pass_update_request(char *line, passdb_context *ctx, int sync)
     int input_idx = 0;
     int eol = 0;
 
+    memset(buffer, 0, sizeof(char)*LINE_BUFFER_SIZE);
+
     //Extract the first tab-delimited field from the input line...
     input_idx += get_field(buffer, line + input_idx, sizeof(buffer), &eol);
 
@@ -1407,6 +1409,9 @@ int main(int argc, char **argv)
         server_fd = -1;
     }
 
+    printf("Unloading rules...\n");
+    unload_rules();
+
     printf("Goodbye.\n");
 
     return 0;

+ 7 - 3
busunit/passdb/passdb.c

@@ -345,7 +345,7 @@ int format_new_passdb()
 
     if( fd < 0 )
     {
-        fprintf(stderr, "Cannot create pass file!\n");
+        fprintf(stderr, "Cannot create pass file '%s'!\n", PASSES_FILE);
         return FAIL_DATABASE;
     }
 
@@ -355,7 +355,7 @@ int format_new_passdb()
     {
         if( write(fd, &blank, sizeof(blank)) != sizeof(blank) )
         {
-            fprintf(stderr, "Cannot write blank data to passes file!\n");
+            fprintf(stderr, "Cannot write blank data to passes file '%s'!\n", PASSES_FILE);
             close(fd);
             return FAIL_DATABASE;
         }
@@ -449,7 +449,7 @@ int attach_to_passdb(passdb_context *ctx)
 
     if(fd < 0)
     {
-        fprintf(stderr, "Cannot open passes file!\n");
+        fprintf(stderr, "Cannot open passes file '%s'!\n", PASSES_FILE);
         return FAIL_DATABASE;
     }
 
@@ -819,6 +819,10 @@ int update_rider(passdb_context *ctx, rider_record *rec, int sync)
     mag_idx = find_mag_in_hash(ctx, rec->magstripe_value);
     rf_idx = find_rf_in_hash(ctx, rec->rfid_value);
 
+    if ((mag_idx < 0) || (rf_idx < 0)) {
+      //pass
+    }
+
 //  We want to allow a short period of magstrip or RFID collision as the lesser of two evils vs.       **STUPID**
 //  possibly losing a record due to a degenerately stupid administrator doing the following:
 //