diff --git a/pkg/device/deviceSwitch/ascendSwitch.go b/pkg/device/deviceSwitch/ascendSwitch.go index d442665ef2d10f59edcd6b13150844a56515da7a..c86d050a1144b737840e6b2d9dead1cf2a0bdf9a 100644 --- a/pkg/device/deviceSwitch/ascendSwitch.go +++ b/pkg/device/deviceSwitch/ascendSwitch.go @@ -18,6 +18,7 @@ package deviceSwitch import ( "context" "fmt" + "runtime" "sync" "time" "unsafe" @@ -48,12 +49,12 @@ import ( // dcmi int (*lq_dcmi_init_func)(); static int dcmi_init_lq(){ - lq_dcmi_init_func(); + return lq_dcmi_init_func(); } int (*lq_dcmi_get_fault_info_func)(unsigned int list_len, unsigned int *event_list_len, struct LqDcmiEvent *event_list); static int lq_dcmi_get_fault_info(unsigned int list_len, unsigned int *event_list_len, struct LqDcmiEvent *event_list){ - lq_dcmi_get_fault_info_func(list_len,event_list_len,event_list); + return lq_dcmi_get_fault_info_func(list_len,event_list_len,event_list); } void goFaultEventHandler(struct LqDcmiEvent *fault_event); @@ -63,7 +64,7 @@ import ( int(*lq_dcmi_subscribe_fault_event_func)(struct lq_dcmi_event_filter filter,lq_dcmi_fault_event_callback handler); static int lq_dcmi_subscribe_fault_event(struct lq_dcmi_event_filter filter){ - lq_dcmi_subscribe_fault_event_func(filter,event_handler); + return lq_dcmi_subscribe_fault_event_func(filter,event_handler); } // load .so files and functions @@ -205,6 +206,7 @@ func goFaultEventHandler(event *C.struct_LqDcmiEvent) { // GetSwitchFaultCodeByInterval start a none stop loop to query and update switch fault code func (sdm *SwitchDevManager) GetSwitchFaultCodeByInterval(ctx context.Context, interval time.Duration) { + runtime.LockOSThread() for { select { case _, ok := <-ctx.Done():