comparison src/core/ngx_cycle.c @ 7394:650574a44505

Core: free shared memory on cycle initialization failure.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 15 Nov 2018 15:28:54 +0300
parents 7bf3c323cb6e
children 9c038f5e0464
comparison
equal deleted inserted replaced
7393:4698cede59ff 7394:650574a44505
841 ngx_close_file_n " \"%s\" failed", 841 ngx_close_file_n " \"%s\" failed",
842 file[i].name.data); 842 file[i].name.data);
843 } 843 }
844 } 844 }
845 845
846 /* free the newly created shared memory */
847
848 part = &cycle->shared_memory.part;
849 shm_zone = part->elts;
850
851 for (i = 0; /* void */ ; i++) {
852
853 if (i >= part->nelts) {
854 if (part->next == NULL) {
855 break;
856 }
857 part = part->next;
858 shm_zone = part->elts;
859 i = 0;
860 }
861
862 if (shm_zone[i].shm.addr == NULL) {
863 continue;
864 }
865
866 opart = &old_cycle->shared_memory.part;
867 oshm_zone = opart->elts;
868
869 for (n = 0; /* void */ ; n++) {
870
871 if (n >= opart->nelts) {
872 if (opart->next == NULL) {
873 break;
874 }
875 opart = opart->next;
876 oshm_zone = opart->elts;
877 n = 0;
878 }
879
880 if (shm_zone[i].shm.name.len != oshm_zone[n].shm.name.len) {
881 continue;
882 }
883
884 if (ngx_strncmp(shm_zone[i].shm.name.data,
885 oshm_zone[n].shm.name.data,
886 shm_zone[i].shm.name.len)
887 != 0)
888 {
889 continue;
890 }
891
892 if (shm_zone[i].tag == oshm_zone[n].tag
893 && shm_zone[i].shm.size == oshm_zone[n].shm.size
894 && !shm_zone[i].noreuse)
895 {
896 goto old_shm_zone_found;
897 }
898
899 break;
900 }
901
902 ngx_shm_free(&shm_zone[i].shm);
903
904 old_shm_zone_found:
905
906 continue;
907 }
908
846 if (ngx_test_config) { 909 if (ngx_test_config) {
847 ngx_destroy_cycle_pools(&conf); 910 ngx_destroy_cycle_pools(&conf);
848 return NULL; 911 return NULL;
849 } 912 }
850 913
1272 return NULL; 1335 return NULL;
1273 } 1336 }
1274 1337
1275 shm_zone->data = NULL; 1338 shm_zone->data = NULL;
1276 shm_zone->shm.log = cf->cycle->log; 1339 shm_zone->shm.log = cf->cycle->log;
1340 shm_zone->shm.addr = NULL;
1277 shm_zone->shm.size = size; 1341 shm_zone->shm.size = size;
1278 shm_zone->shm.name = *name; 1342 shm_zone->shm.name = *name;
1279 shm_zone->shm.exists = 0; 1343 shm_zone->shm.exists = 0;
1280 shm_zone->init = NULL; 1344 shm_zone->init = NULL;
1281 shm_zone->tag = tag; 1345 shm_zone->tag = tag;