diff options
| author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-30 14:12:28 +0000 | 
|---|---|---|
| committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-08-30 14:12:28 +0000 | 
| commit | 399164eff1c6d07056ec93e3afd4079611cf9c7b (patch) | |
| tree | befee04fa22eeb818d8710e44fa6a9b669a01745 /src/ipcpd/shim-data.c | |
| parent | 8fe0340d2117cf9b5c724ff10621978ef2bee5f1 (diff) | |
| parent | a770296c7aa15057602a4e4f5c7744ccfc65b8aa (diff) | |
| download | ouroboros-399164eff1c6d07056ec93e3afd4079611cf9c7b.tar.gz ouroboros-399164eff1c6d07056ec93e3afd4079611cf9c7b.zip  | |
Merged in sandervrijders/ouroboros/be-connect (pull request #582)
Be connect
Diffstat (limited to 'src/ipcpd/shim-data.c')
| -rw-r--r-- | src/ipcpd/shim-data.c | 17 | 
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ipcpd/shim-data.c b/src/ipcpd/shim-data.c index 355cec68..2d6585b5 100644 --- a/src/ipcpd/shim-data.c +++ b/src/ipcpd/shim-data.c @@ -24,6 +24,10 @@  #include "config.h" +#define OUROBOROS_PREFIX "shim-data" + +#include <ouroboros/endian.h> +#include <ouroboros/logs.h>  #include <ouroboros/list.h>  #include <ouroboros/time_utils.h>  #include <ouroboros/errno.h> @@ -260,9 +264,10 @@ static struct dir_entry * find_dir_entry_any(struct shim_data * data,  }  int shim_data_reg_add_entry(struct shim_data * data, -                            uint8_t *          hash) +                            const uint8_t *    hash)  {          struct reg_entry * entry; +        uint8_t *          hash_dup;          assert(data);          assert(hash); @@ -271,10 +276,18 @@ int shim_data_reg_add_entry(struct shim_data * data,          if (find_reg_entry_by_hash(data, hash)) {                  pthread_rwlock_unlock(&data->reg_lock); +                log_dbg(HASH_FMT " was already in the directory.", +                        HASH_VAL(hash)); +                return 0; +        } + +        hash_dup = ipcp_hash_dup(hash); +        if (hash_dup == NULL) { +                pthread_rwlock_unlock(&data->reg_lock);                  return -1;          } -        entry = reg_entry_create(hash); +        entry = reg_entry_create(hash_dup);          if (entry == NULL) {                  pthread_rwlock_unlock(&data->reg_lock);                  return -1;  | 
