- if (data->fd >= 0) rad_lockfd(data->fd, sizeof(int));
- rcode = gdbm_store(data->gdbm, key_datum, data_datum, GDBM_REPLACE);
- if (data->fd >= 0) rad_unlockfd(data->fd, sizeof(int));
- if (rcode < 0) {
- radlog(L_ERR, "rlm_ippool: Failed storing data to %s: %s",
- data->session_db, gdbm_strerror(gdbm_errno));
- return RLM_MODULE_FAIL;
- }
- /* Decrease allocated count from the ip index */
-
- key_datum.dptr = (uint32_t *) &entry.ipaddr;
- key_datum.dsize = sizeof(uint32_t);
- if (data->ip_fd >= 0) rad_lockfd(data->ip_fd, sizeof(int));
- data_datum = gdbm_fetch(data->ip, key_datum);
- if (data->ip_fd >= 0) rad_unlockfd(data->ip_fd, sizeof(int));
- if (data_datum.dptr != NULL){
- memcpy(&num, data_datum.dptr, sizeof(int));
- free(data_datum.dptr);
- if (num >0){
- num--;
- DEBUG("rlm_ippool: num: %d",num);
- data_datum.dptr = (int *) #
- data_datum.dsize = sizeof(int);
- if (data->ip_fd >= 0) rad_lockfd(data->ip_fd, sizeof(int));
- rcode = gdbm_store(data->ip, key_datum, data_datum, GDBM_REPLACE);
- if (data->ip_fd >= 0) rad_unlockfd(data->ip_fd, sizeof(int));
- if (rcode < 0) {
- radlog(L_ERR, "rlm_ippool: Failed storing data to %s: %s",
- data->ip_index, gdbm_strerror(gdbm_errno));
- return RLM_MODULE_FAIL;
- }
+ rcode = gdbm_store(data->gdbm, key_datum, data_datum, GDBM_REPLACE);
+ if (rcode < 0) {
+ radlog(L_ERR, "rlm_ippool: Failed storing data to %s: %s",
+ data->session_db, gdbm_strerror(gdbm_errno));
+ pthread_mutex_unlock(&data->op_mutex);
+ return RLM_MODULE_FAIL;
+ }
+ /* Decrease allocated count from the ip index */
+
+ key_datum.dptr = (char *) &entry.ipaddr;
+ key_datum.dsize = sizeof(uint32_t);
+ data_datum = gdbm_fetch(data->ip, key_datum);
+ if (data_datum.dptr != NULL){
+ memcpy(&num, data_datum.dptr, sizeof(int));
+ free(data_datum.dptr);
+ if (num >0){
+ num--;
+ RDEBUG("num: %d",num);
+ data_datum.dptr = (char *) #
+ data_datum.dsize = sizeof(int);
+ rcode = gdbm_store(data->ip, key_datum, data_datum, GDBM_REPLACE);
+ if (rcode < 0) {
+ radlog(L_ERR, "rlm_ippool: Failed storing data to %s: %s",
+ data->ip_index, gdbm_strerror(gdbm_errno));
+ pthread_mutex_unlock(&data->op_mutex);
+ return RLM_MODULE_FAIL;
+ }
+ if (num >0 && entry.extra == 1){
+ /*
+ * We are doing MPPP and we still have nas/port entries referencing
+ * this ip. Delete this entry so that eventually we only keep one
+ * reference to this ip.
+ */
+ gdbm_delete(data->gdbm,save_datum);