Fix compilation errors for non-test builds

Fixed build errors in tinydfs_server and example_client targets caused
by missing timeout parameter and simulation client references.

**Changes:**

**main_server.c:**
- Added int timeout variable declaration in metadata_server_main()
- Added int timeout variable declaration in chunk_server_main()
- Pass &timeout to metadata_server_init() call
- Pass &timeout to metadata_server_step() call
- Pass &timeout to chunk_server_init() call
- Pass &timeout to chunk_server_step() call

**system.c:**
- Guarded simulation_client.h include with #ifdef BUILD_TEST
- Guarded PROCESS_TYPE_CLIENT enum value with #ifdef BUILD_TEST
- Guarded SimulationClient member in Process union with #ifdef BUILD_TEST
- Guarded is_client() function with #ifdef BUILD_TEST
- Guarded client detection logic in spawn_simulated_process()
- Guarded PROCESS_TYPE_CLIENT cases in all switch statements:
  - spawn_simulated_process() init switch
  - free_process() cleanup switch
  - update_simulation() step switch

**Result:**
- tinydfs_server.out now compiles successfully
- example_client.out now compiles successfully
- tinydfs_test.out continues to work correctly
- Simulation client code only included when BUILD_TEST is defined
- All three build targets pass compilation with only pre-existing warnings

The simulation_client code is now properly isolated to test builds only,
preventing linker errors when building the real server and example client.
This commit is contained in:
Claude
2025-11-02 13:05:34 +00:00
parent 88a3a6e4f0
commit dc4fb33be2
2 changed files with 26 additions and 5 deletions
+6 -4
View File
@@ -18,14 +18,15 @@ int metadata_server_main(int argc, char **argv)
void *contexts[MAX_CONNS+1];
struct pollfd polled[MAX_CONNS+1];
int num_polled;
int timeout;
MetadataServer state;
num_polled = metadata_server_init(
&state, argc, argv, contexts, polled);
&state, argc, argv, contexts, polled, &timeout);
if (num_polled < 0) return -1;
for (;;) {
POLL(polled, num_polled, -1);
num_polled = metadata_server_step(
&state, contexts, polled, num_polled);
&state, contexts, polled, num_polled, &timeout);
if (num_polled < 0) return -1;
}
metadata_server_free(&state);
@@ -37,14 +38,15 @@ int chunk_server_main(int argc, char **argv)
void *contexts[MAX_CONNS+1];
struct pollfd polled[MAX_CONNS+1];
int num_polled;
int timeout;
ChunkServer state;
num_polled = chunk_server_init(
&state, argc, argv, contexts, polled);
&state, argc, argv, contexts, polled, &timeout);
if (num_polled < 0) return -1;
for (;;) {
POLL(polled, num_polled, -1);
num_polled = chunk_server_step(
&state, contexts, polled, num_polled);
&state, contexts, polled, num_polled, &timeout);
if (num_polled < 0) return -1;
}
chunk_server_free(&state);