| 192 | |
| 193 | |
| 194 | static inline struct proxy_l* shm_clone_proxy(struct proxy_l *sp, |
| 195 | unsigned int move_dn) |
| 196 | { |
| 197 | struct proxy_l *dp; |
| 198 | |
| 199 | dp = (struct proxy_l*)shm_malloc(sizeof(struct proxy_l)); |
| 200 | if (dp==NULL) { |
| 201 | LM_ERR("no more shm memory\n"); |
| 202 | return 0; |
| 203 | } |
| 204 | memset( dp , 0 , sizeof(struct proxy_l)); |
| 205 | |
| 206 | dp->port = sp->port; |
| 207 | dp->proto = sp->proto; |
| 208 | dp->addr_idx = sp->addr_idx; |
| 209 | dp->flags = PROXY_SHM_FLAG; |
| 210 | |
| 211 | /* clone the hostent */ |
| 212 | if (hostent_shm_cpy( &dp->host, &sp->host)!=0) |
| 213 | goto error0; |
| 214 | |
| 215 | /* clone the dns resolver */ |
| 216 | if (sp->dn) { |
| 217 | if (move_dn) { |
| 218 | dp->dn = sp->dn; |
| 219 | sp->dn = 0; |
| 220 | } else { |
| 221 | dp->dn = dns_res_copy(sp->dn); |
| 222 | if (dp->dn==NULL) |
| 223 | goto error1; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | return dp; |
| 228 | error1: |
| 229 | free_shm_hostent(&dp->host); |
| 230 | error0: |
| 231 | shm_free(dp); |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | |
| 236 |
no test coverage detected