+/* Mark that we are loading in the global state and setup the fields
+ * needed to provide loading stats. */
+void startLoading(FILE *fp) {
+ struct stat sb;
+
+ /* Load the DB */
+ server.loading = 1;
+ server.loading_start_time = time(NULL);
+ if (fstat(fileno(fp), &sb) == -1) {
+ server.loading_total_bytes = 1; /* just to avoid division by zero */
+ } else {
+ server.loading_total_bytes = sb.st_size;
+ }
+}
+
+/* Refresh the loading progress info */
+void loadingProgress(off_t pos) {
+ server.loading_loaded_bytes = pos;
+}
+
+/* Loading finished */
+void stopLoading(void) {
+ server.loading = 0;
+}
+