Overview
Comment: | Fixed file descriptor leaking introduced in [b4fa45b6aa] and made connection re-use more clean |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
679bcc1373c006bfd0e3e17b4de5425e |
User & Date: | rkeene on 2014-10-13 14:59:46 |
Other Links: | manifest | tags |
Context
2014-10-13
| ||
15:00 | Updated version check-in: c261ffbca5 user: rkeene tags: trunk | |
14:59 | Fixed file descriptor leaking introduced in [b4fa45b6aa] and made connection re-use more clean check-in: 679bcc1373 user: rkeene tags: trunk | |
08:12 | Post-release version increment check-in: 7099ed9113 user: rkeene tags: trunk | |
Changes
Modified filed.c from [5391cbc0bc] to [390765784d].
︙ | ︙ | |||
933 934 935 936 937 938 939 | log->buffer[0] = '\0'; log->http_code = -1; log->reason = "fdopen_failed"; filed_log_entry(log); | | | | | | | 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | log->buffer[0] = '\0'; log->http_code = -1; log->reason = "fdopen_failed"; filed_log_entry(log); return(FILED_CONNECTION_CLOSE); } request = filed_get_http_request(fp, request, options); if (request == NULL) { log->buffer[0] = '\0'; filed_error_page(fp, date_current, 500, FILED_REQUEST_METHOD_GET, "format", log); return(FILED_CONNECTION_CLOSE); } path = request->path; strcpy(log->buffer, path); log->method = request->method; /* If the requested path is a directory, redirect to index page */ if (request->type == FILED_REQUEST_TYPE_DIRECTORY) { filed_redirect_index(fp, date_current, path, log); return(FILED_CONNECTION_CLOSE); } fileinfo = filed_open_file(path, &request->fileinfo); if (fileinfo == NULL) { filed_error_page(fp, date_current, 404, request->method, "open_failed", log); return(FILED_CONNECTION_CLOSE); } if (request->headers.range.present) { if (request->headers.range.offset != 0 || request->headers.range.length >= 0) { if (request->headers.range.offset >= fileinfo->len) { filed_error_page(fp, date_current, 416, request->method, "range_invalid", log); close(fileinfo->fd); return(FILED_CONNECTION_CLOSE); } if (request->headers.range.length == ((off_t) -1)) { filed_log_msg_debug("Computing length to fit in bounds: fileinfo->len = %llu, request->headers.range.offset = %llu", (unsigned long long) fileinfo->len, (unsigned long long) request->headers.range.offset ); |
︙ | ︙ | |||
1095 1096 1097 1098 1099 1100 1101 1102 | } } log->endtime = (time_t) -1; log->sent_length = sendfile_sent; filed_log_entry(log); | < | > | | | | 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 | } } log->endtime = (time_t) -1; log->sent_length = sendfile_sent; filed_log_entry(log); close(fileinfo->fd); if (request->headers.connection != FILED_CONNECTION_KEEP_ALIVE) { fclose(fp); return(FILED_CONNECTION_CLOSE); } return(FILED_CONNECTION_KEEP_ALIVE); } /* Handle incoming connections */ static void *filed_worker_thread(void *arg_v) { struct filed_worker_thread_args *arg; struct filed_http_request request; struct filed_log_entry *log, local_dummy_log; struct filed_options *options; struct sockaddr_in6 addr; socklen_t addrlen; int failure_count = 0, max_failure_count = FILED_MAX_FAILURE_COUNT; int connection_state = FILED_CONNECTION_CLOSE; int master_fd, fd = -1; /* Read arguments */ arg = arg_v; master_fd = arg->fd; options = &arg->options; |
︙ | ︙ | |||
1141 1142 1143 1144 1145 1146 1147 | filed_log_msg("ALLOCATE_LOG_MSG_FAILED"); break; } log->type = FILED_LOG_TYPE_TRANSFER; | > > | < > | 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 | filed_log_msg("ALLOCATE_LOG_MSG_FAILED"); break; } log->type = FILED_LOG_TYPE_TRANSFER; /* If we closed the old connection, accept a new one */ if (connection_state == FILED_CONNECTION_CLOSE) { /* Accept a new client */ addrlen = sizeof(addr); fd = accept(master_fd, (struct sockaddr *) &addr, &addrlen); } /* * If we fail, make a note of it so we don't go into a loop of * accept() failing */ |
︙ | ︙ | |||
1174 1175 1176 1177 1178 1179 1180 | log->port = addr.sin6_port; } /* Reset failure count*/ failure_count = 0; /* Handle socket */ | | | 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 | log->port = addr.sin6_port; } /* Reset failure count*/ failure_count = 0; /* Handle socket */ connection_state = filed_handle_client(fd, &request, log, options); } /* Report error */ filed_log_msg("THREAD_DIED ABNORMAL"); return(NULL); |
︙ | ︙ |