MCPcopy Create free account
hub / github.com/apache/httpd / md_util_freplace

Function md_util_freplace

modules/md/md_util.c:433–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431}
432
433apr_status_t md_util_freplace(const char *fpath, apr_fileperms_t perms, apr_pool_t *p,
434 md_util_file_cb *write_cb, void *baton)
435{
436 apr_status_t rv = APR_EEXIST;
437 apr_file_t *f;
438 const char *tmp;
439 int i, max;
440
441 tmp = apr_psprintf(p, "%s.tmp", fpath);
442 i = 0; max = 20;
443creat:
444 while (i < max && APR_EEXIST == (rv = md_util_fcreatex(&f, tmp, perms, p))) {
445 ++i;
446 apr_sleep(apr_time_from_msec(50));
447 }
448 if (APR_EEXIST == rv
449 && APR_SUCCESS == (rv = apr_file_remove(tmp, p))
450 && max <= 20) {
451 max *= 2;
452 goto creat;
453 }
454
455 if (APR_SUCCESS == rv) {
456 rv = write_cb(baton, f, p);
457 apr_file_close(f);
458
459 if (APR_SUCCESS == rv) {
460 rv = apr_file_rename(tmp, fpath, p);
461 if (APR_SUCCESS != rv) {
462 apr_file_remove(tmp, p);
463 }
464 }
465 }
466 return rv;
467}
468
469/**************************************************************************************************/
470/* text files */

Callers 4

md_pkey_fsaveFunction · 0.85
md_cert_fsaveFunction · 0.85
md_json_freplaceFunction · 0.85
md_text_freplaceFunction · 0.85

Calls 1

md_util_fcreatexFunction · 0.85

Tested by

no test coverage detected