Changeset 765 for trunk/zoo-project/zoo-kernel/zoo_service_loader.c
- Timestamp:
- May 30, 2016, 7:12:12 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r752 r765 161 161 str[i] = toReplaceBy; 162 162 } 163 } 164 165 /** 166 * Dump back the final file fbkp1 to fbkp 167 * 168 * @param m the conf maps containing the main.cfg settings 169 * @param fbkp the string corresponding to the name of the file 170 * @param fbkp1 the string corresponding to the name of the file 171 */ 172 int dumpBackFinalFile(maps* m,char* fbkp,char* fbkp1) 173 { 174 FILE *f2 = fopen (fbkp1, "rb"); 175 #ifndef RELY_ON_DB 176 semid lid = getShmLockId (m, 1); 177 if (lid < 0) 178 return -1; 179 lockShm (lid); 180 #endif 181 FILE *f3 = fopen (fbkp, "wb+"); 182 free (fbkp); 183 fseek (f2, 0, SEEK_END); 184 long flen = ftell (f2); 185 fseek (f2, 0, SEEK_SET); 186 char *tmps1 = (char *) malloc ((flen + 1) * sizeof (char)); 187 fread (tmps1, flen, 1, f2); 188 #ifdef WIN32 189 char *pchr=strrchr(tmps1,'>'); 190 flen=strlen(tmps1)-strlen(pchr)+1; 191 tmps1[flen]=0; 192 #endif 193 fwrite (tmps1, 1, flen, f3); 194 fclose (f2); 195 fclose (f3); 196 return 1; 163 197 } 164 198 … … 2137 2171 freeService (&s1); 2138 2172 free (s1); 2173 fclose (f0); 2174 fclose (f1); 2175 if(dumpBackFinalFile(m,fbkp,fbkp1)<0) 2176 return -1; 2177 unlink (fbkpid); 2178 unhandleStatus (m); 2139 2179 freeMaps (&m); 2140 2180 free (m); … … 2149 2189 fflush (stdout); 2150 2190 fflush (stderr); 2151 unhandleStatus (m);2152 2191 return -1; 2153 2192 } … … 2190 2229 signal (SIGABRT, donothing); 2191 2230 #endif 2231 2192 2232 if (((int) getpid ()) != cpid || cgiSid != NULL) 2193 2233 { 2194 2234 fclose (stdout); 2195 2235 fclose (stderr); 2196 /** 2197 * Dump back the final file fbkp1 to fbkp 2198 */ 2236 2199 2237 fclose (f0); 2200 2238 fclose (f1); 2201 2239 2202 FILE *f2 = fopen (fbkp1, "rb"); 2203 #ifndef RELY_ON_DB 2204 semid lid = getShmLockId (m, 1); 2205 if (lid < 0) 2206 return -1; 2207 lockShm (lid); 2208 #endif 2209 FILE *f3 = fopen (fbkp, "wb+"); 2210 free (fbkp); 2211 fseek (f2, 0, SEEK_END); 2212 long flen = ftell (f2); 2213 fseek (f2, 0, SEEK_SET); 2214 char *tmps1 = (char *) malloc ((flen + 1) * sizeof (char)); 2215 fread (tmps1, flen, 1, f2); 2216 #ifdef WIN32 2217 char *pchr=strrchr(tmps1,'>'); 2218 flen=strlen(tmps1)-strlen(pchr)+1; 2219 tmps1[flen]=0; 2220 #endif 2221 fwrite (tmps1, 1, flen, f3); 2222 fclose (f2); 2223 fclose (f3); 2240 if(dumpBackFinalFile(m,fbkp,fbkp1)<0) 2241 return -1; 2242 2224 2243 unlink (fbkpid); 2225 2244 switch(eres){
Note: See TracChangeset
for help on using the changeset viewer.