Obsolete
/
libipc-old
Archived
3
0
Fork 0

Do not quit after timeout.

master
Karchnu 2022-12-26 08:21:29 +01:00
parent e7c1c8b96d
commit 1a161d1b14
1 changed files with 14 additions and 10 deletions

View File

@ -38,6 +38,8 @@ test {
_ = @import("./util.zig"); _ = @import("./util.zig");
} }
var should_quit: bool = false;
fn create_service() !void { fn create_service() !void {
const config = .{.safety = true}; const config = .{.safety = true};
var gpa = std.heap.GeneralPurposeAllocator(config){}; var gpa = std.heap.GeneralPurposeAllocator(config){};
@ -52,7 +54,8 @@ fn create_service() !void {
// SERVER SIDE: creating a service. // SERVER SIDE: creating a service.
_ = try ctx.server_init(path); _ = try ctx.server_init(path);
var count_down: i16 = 5; // TODO: signal handler, to quit when asked
var some_event: Event = undefined; var some_event: Event = undefined;
ctx.timer = 2000; // 1 second ctx.timer = 2000; // 1 second
while(true) { while(true) {
@ -62,19 +65,16 @@ fn create_service() !void {
print("New connection: {}!\n", .{some_event}); print("New connection: {}!\n", .{some_event});
}, },
.TIMER => { .TIMER => {
print("Timer! ({})\n", .{count_down}); print("Timer!\n", .{});
count_down -= 1;
if(count_down < 0) {
print("STOP WAITING!\n", .{});
break;
}
}, },
.EXTERNAL => { .EXTERNAL => {
print("Message received from a non IPC socket.\n", .{}); print("Message received from a non IPC socket.\n", .{});
print("NOT IMPLEMENTED, YET. It's a suicide, then.\n", .{});
break; break;
}, },
.SWITCH => { .SWITCH => {
print("Message to send to a corresponding fd.\n", .{}); print("Message to send to a corresponding fd.\n", .{});
print("NOT IMPLEMENTED, YET. It's a suicide, then.\n", .{});
break; break;
}, },
.DISCONNECTION => { .DISCONNECTION => {
@ -89,21 +89,25 @@ fn create_service() !void {
}, },
.LOOKUP => { .LOOKUP => {
print("Client asking for a service through ipcd.\n", .{}); print("Client asking for a service through ipcd.\n", .{});
print("NOT IMPLEMENTED, YET. It's a suicide, then.\n", .{});
break; break;
}, },
.TX => { .TX => {
print("Message sent.\n", .{}); print("Message sent.\n", .{});
break;
}, },
.NOT_SET => { .NOT_SET => {
print("Event type not set.\n", .{}); print("Event type not set. Something is wrong, let's suicide.\n", .{});
break; break;
}, },
.ERROR => { .ERROR => {
print("A problem occured, event: {}\n", .{some_event}); print("A problem occured, event: {}, let's suicide\n", .{some_event});
break; break;
}, },
} }
if (should_quit) {
break;
}
} }