Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
0291-Fix-communication-with-port-program-win32s...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0291-Fix-communication-with-port-program-win32sysinfo.exe.patch of Package erlang
From 11584fd10f7a01f800db213e4ad16e59d2f0d0a0 Mon Sep 17 00:00:00 2001 From: Luke Bakken <luke@bakken.io> Date: Wed, 7 Sep 2022 13:49:30 -0700 Subject: [PATCH] Fix communication with port program `win32sysinfo.exe` The `COMMUNICATION` section in `lib/os_mon/c_src/win32sysinfo.c` specifies how to communicate with the port program. These changes fix the expected input data for retrieving information for a single drive. Ensure that get_disk_info/1 arguments and processing work together. The port program takes a single drive letter, not a list. Fixes #6156 --- lib/os_mon/c_src/win32sysinfo.c | 47 +++++++++++++++---------------- lib/os_mon/src/os_mon_sysinfo.erl | 10 +++---- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib/os_mon/c_src/win32sysinfo.c b/lib/os_mon/c_src/win32sysinfo.c index 1c9590fb8b..85622e0076 100644 --- a/lib/os_mon/c_src/win32sysinfo.c +++ b/lib/os_mon/c_src/win32sysinfo.c @@ -265,31 +265,30 @@ message_loop() print_error("Erlang has closed"); return; } + if ((res = read(0, &cmd, cmdLen)) == cmdLen){ if (cmdLen == 1) { - switch (cmd[0]) { - case MEM_INFO: - get_avail_mem_ext(); - return_answer(OK); - break; - case DISK_INFO: - get_disk_info_all(); - return_answer(OK); - break; - default: /* ignore all other messages */ - break; - } /* switch */ + switch (cmd[0]) { + case MEM_INFO: + get_avail_mem_ext(); + return_answer(OK); + break; + case DISK_INFO: + get_disk_info_all(); + return_answer(OK); + break; + default: /* ignore all other messages */ + break; + } /* switch */ } - else - if ((res > 0) && (cmd[0]==DISK_INFO)) { - cmd[cmdLen] = 0; - output_drive_info(&cmd[1]); - return_answer("OK"); - return; - } - else - return_answer("xEND"); - } + else { + if ((res > 0) && (cmd[0]==DISK_INFO)) { + cmd[cmdLen] = 0; + output_drive_info(&cmd[1]); + } + return_answer(OK); + } + } else if (res == 0) { print_error("Erlang has closed"); return; @@ -297,8 +296,8 @@ message_loop() else { print_error("Error reading from Erlang"); return; - } - } + } + } } int main(int argc, char ** argv){ diff --git a/lib/os_mon/src/os_mon_sysinfo.erl b/lib/os_mon/src/os_mon_sysinfo.erl index 4f5a682a1f..662d984dfd 100644 --- a/lib/os_mon/src/os_mon_sysinfo.erl +++ b/lib/os_mon/src/os_mon_sysinfo.erl @@ -45,7 +45,7 @@ get_disk_info() -> gen_server:call(os_mon_sysinfo, get_disk_info). get_disk_info(DriveRoot) -> - gen_server:call(os_mon_sysinfo, {get_disk_info,DriveRoot}). + gen_server:call(os_mon_sysinfo, {get_disk_info, DriveRoot}). get_mem_info() -> gen_server:call(os_mon_sysinfo, get_mem_info). @@ -65,8 +65,8 @@ init([]) -> handle_call(get_disk_info, _From, State) -> {reply, get_disk_info1(State#state.port), State}; -handle_call({get_disk_info,RootList}, _From, State) -> - {reply, get_disk_info1(State#state.port,RootList), State}; +handle_call({get_disk_info, DriveRoot}, _From, State) -> + {reply, get_disk_info1(State#state.port, DriveRoot), State}; handle_call(get_mem_info, _From, State) -> {reply, get_mem_info1(State#state.port), State}. @@ -108,8 +108,8 @@ get_disk_info1(Port) -> Port ! {self(),{command,[?DISK_INFO]}}, get_data(Port,[]). -get_disk_info1(Port,PathList) -> - Port ! {self(),{command,[?DISK_INFO|[P++[0]||P <- PathList]]}}, +get_disk_info1(Port, DriveRoot) -> + Port ! {self(), {command,[?DISK_INFO|DriveRoot++[0]]}}, get_data(Port,[]). get_mem_info1(Port) -> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor