* Close a file returned by OpenTransientFile. * * Note we do not check close's return value --- it is up to the caller * to handle close errors. */
| 2729 | * to handle close errors. |
| 2730 | */ |
| 2731 | int |
| 2732 | CloseTransientFile(int fd) |
| 2733 | { |
| 2734 | int i; |
| 2735 | |
| 2736 | DO_DB(elog(LOG, "CloseTransientFile: Allocated %d", numAllocatedDescs)); |
| 2737 | |
| 2738 | /* Remove fd from list of allocated files, if it's present */ |
| 2739 | for (i = numAllocatedDescs; --i >= 0;) |
| 2740 | { |
| 2741 | AllocateDesc *desc = &allocatedDescs[i]; |
| 2742 | |
| 2743 | if (desc->kind == AllocateDescRawFD && desc->desc.fd == fd) |
| 2744 | return FreeDesc(desc); |
| 2745 | } |
| 2746 | |
| 2747 | /* Only get here if someone passes us a file not in allocatedDescs */ |
| 2748 | elog(WARNING, "fd passed to CloseTransientFile was not obtained from OpenTransientFile"); |
| 2749 | |
| 2750 | return close(fd); |
| 2751 | } |
| 2752 | |
| 2753 | /* |
| 2754 | * Routines that want to use <dirent.h> (ie, DIR*) should use AllocateDir |
no test coverage detected