mx_status_type mx_list_head_print_clients( MX_LIST_HEAD *list_head ) { static const char fname[] = "mx_list_head_print_clients()"; MX_SOCKET_HANDLER_LIST *socket_handler_list; MX_SOCKET_HANDLER *socket_handler; struct mx_event_handler_type *event_handler; int i; if ( list_head->application_ptr == NULL ) { return mx_error( MXE_ILLEGAL_ARGUMENT, fname, "The database list head application pointer has not been initialized." ); } socket_handler_list = list_head->application_ptr; mx_info( "Num sock type host user pid program" ); mx_info( "---------------------------------------------------------------" ); for ( i = 0; i < socket_handler_list->handler_array_size; i++ ) { socket_handler = socket_handler_list->array[i]; if ( socket_handler != NULL ) { event_handler = socket_handler->event_handler; if ( event_handler == NULL ) { (void) mx_error( MXE_CORRUPT_DATA_STRUCTURE, fname, "Event_handler pointer for client %d is NULL.", i ); continue; } mx_info( "%3d %3d %s %-16s %-8s %6ld %-8s", i, (int) socket_handler->mx_socket->socket_fd, event_handler->name, socket_handler->client_address_string, socket_handler->username, (long) socket_handler->process_id, socket_handler->program_name ); } } return MX_SUCCESSFUL_RESULT; }
MX_EXPORT int mx_heap_check( unsigned long heap_flags ) { static const char fname[] = "mx_heap_check()"; boolean_t ok; mx_bool_type heap_ok; heap_ok = TRUE; ok = malloc_zone_check( NULL ); if ( ok ) { if ( heap_flags & MXF_HEAP_CHECK_OK ) { mx_info("%s: Heap is OK.", fname); } } else { if ( heap_flags & MXF_HEAP_CHECK_CORRUPTED ) { mx_warning("%s: Heap is corrupted.", fname); } heap_ok = FALSE; } return heap_ok; }
mx_status_type mx_list_head_show_system_memory( MX_LIST_HEAD *list_head ) { mx_status_type mx_status; MX_SYSTEM_MEMINFO meminfo; mx_info( "Computer '%s' memory usage:", list_head->hostname ); mx_status = mx_get_system_meminfo( &meminfo ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; mx_display_system_meminfo( &meminfo ); return MX_SUCCESSFUL_RESULT; }
mx_status_type mx_list_head_show_process_memory( MX_LIST_HEAD *list_head ) { mx_status_type mx_status; unsigned long process_id; MX_PROCESS_MEMINFO meminfo; process_id = mx_process_id(); mx_info( "Process %lu memory usage:", process_id ); mx_status = mx_get_process_meminfo( process_id, &meminfo ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; mx_display_process_meminfo( &meminfo ); return MX_SUCCESSFUL_RESULT; }
MX_EXPORT mx_status_type mxi_isobus_command( MX_ISOBUS *isobus, long isobus_address, char *command, char *response, size_t max_response_length, long maximum_retries, unsigned long isobus_flags ) { static const char fname[] = "mxi_isobus_command()"; MX_RECORD *interface_record; long gpib_address; char local_command_buffer[100]; char *command_ptr; size_t length; long i, j, rs232_retries; unsigned long wait_ms, num_input_bytes_available; mx_bool_type error_occurred; mx_status_type mx_status; if ( isobus == (MX_ISOBUS *) NULL ) { return mx_error( MXE_NULL_ARGUMENT, fname, "The MX_ISOBUS pointer passed was NULL." ); } if ( command == (char *) NULL ) { return mx_error( MXE_NULL_ARGUMENT, fname, "The command pointer passed was NULL." ); } interface_record = isobus->isobus_interface.record; if ( interface_record == (MX_RECORD *) NULL ) { return mx_error( MXE_CORRUPT_DATA_STRUCTURE, fname, "The interface record pointer for ISOBUS interface '%s' is NULL.", isobus->record->name ); } /* Format the command to be sent. */ if ( isobus_address < 0 ) { command_ptr = command; } else { command_ptr = local_command_buffer; snprintf( local_command_buffer, sizeof(local_command_buffer), "@%ld%s", isobus_address, command ); } if ( maximum_retries < 0 ) { maximum_retries = LONG_MAX; } error_occurred = FALSE; for ( i = 0; i <= maximum_retries; i++ ) { if ( i > 0 ) { mx_info( "ISOBUS interface '%s' command retry #%ld.", isobus->record->name, i ); } /* Send the command and get the response. */ if ( isobus_flags & MXF_ISOBUS_DEBUG ) { MX_DEBUG(-2,("%s: sending command '%s' to '%s'.", fname, command_ptr, isobus->record->name)); } error_occurred = FALSE; if ( interface_record->mx_class == MXI_RS232 ) { mx_status = mx_rs232_putline( interface_record, command_ptr, NULL, 0 ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; if ( response != NULL ) { /* Wait for the response. */ rs232_retries = 50; wait_ms = 100; for ( j = 0; j <= rs232_retries; j++ ) { /* See if the first character * has arrived. */ mx_status = mx_rs232_num_input_bytes_available( interface_record, &num_input_bytes_available ); if ( mx_status.code != MXE_SUCCESS ) { /* Exit the for(j) loop. */ break; } if ( num_input_bytes_available > 0 ) { /* Exit the for(j) loop. */ break; } } if ( mx_status.code != MXE_SUCCESS ) { error_occurred = TRUE; } else { /* Read in the response. */ mx_status = mx_rs232_getline( interface_record, response, max_response_length, NULL, 0); if ( mx_status.code != MXE_SUCCESS ) { error_occurred = TRUE; } else { /* Remove any trailing carriage * return characters. */ length = strlen( response ); if (length < max_response_length ) { if ( response[length-1] == MX_CR ) { response[length-1] = '\0'; } } } } } } else { /* GPIB */ gpib_address = isobus->isobus_interface.address; mx_status = mx_gpib_putline( interface_record, gpib_address, command_ptr, NULL, 0 ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; if ( response != NULL ) { mx_status = mx_gpib_getline( interface_record, gpib_address, response, max_response_length, NULL, 0); if ( mx_status.code != MXE_SUCCESS ) { error_occurred = TRUE; } } } if ( error_occurred == FALSE ) { /* If the first character in the response is a * question mark '?', then an error occurred. */ if ( response != NULL ) { if ( response[0] == '?' ) { mx_status = mx_error( MXE_DEVICE_ACTION_FAILED, fname, "The command '%s' to ISOBUS interface '%s' failed. " "Controller error message = '%s'", command_ptr, isobus->record->name, response ); error_occurred = TRUE; } else { if ( isobus_flags & MXF_ISOBUS_DEBUG ) { MX_DEBUG(-2,("%s: received " "response '%s' from '%s'", fname, response, isobus->record->name )); } } } } if ( error_occurred == FALSE ) { break; /* Exit the for() loop. */ } } if ( error_occurred ) { return mx_error( MXE_TIMED_OUT, fname, "The command '%s' to ISOBUS interface '%s' is still failing " "after %ld retries. Giving up...", command_ptr, isobus->record->name, maximum_retries ); } else { return MX_SUCCESSFUL_RESULT; } }
mx_status_type mx_list_head_process_function( void *record_ptr, void *record_field_ptr, void *socket_handler_ptr, int operation ) { static const char fname[] = "mx_list_head_process_function()"; MX_RECORD *record; MX_RECORD_FIELD *record_field; MX_SOCKET_HANDLER *socket_handler; MX_LIST_HEAD *list_head; mx_status_type mx_status; record = (MX_RECORD *) record_ptr; record_field = (MX_RECORD_FIELD *) record_field_ptr; socket_handler = (MX_SOCKET_HANDLER *) socket_handler_ptr; list_head = (MX_LIST_HEAD *) (record->record_superclass_struct); mx_status = MX_SUCCESSFUL_RESULT; switch( operation ) { case MX_PROCESS_GET: switch( record_field->label_value ) { case MXLV_LHD_CFLAGS: /* Just return the value in the cflags field * of the list head. */ break; case MXLV_LHD_DEBUG_LEVEL: list_head->debug_level = mx_get_debug_level(); break; case MXLV_LHD_DEBUGGER_STARTED: list_head->debugger_started = mx_get_debugger_started_flag(); break; case MXLV_LHD_BREAKPOINT_NUMBER: break; case MXLV_LHD_NUMBERED_BREAKPOINT_STATUS: list_head->numbered_breakpoint_status = mx_get_numbered_breakpoint( list_head->breakpoint_number ); break; case MXLV_LHD_POSIX_TIME: list_head->posix_time = mx_posix_time(); break; case MXLV_LHD_SHORT_ERROR_CODES: if ( socket_handler != (MX_SOCKET_HANDLER *) NULL ) { list_head->short_error_codes = socket_handler->short_error_codes; } break; default: MX_DEBUG( 1,( "%s: *** Unknown MX_PROCESS_GET label value = %ld", fname, record_field->label_value)); break; } break; case MX_PROCESS_PUT: switch( record_field->label_value ) { case MXLV_LHD_DEBUG_LEVEL: mx_set_debug_level( (int) list_head->debug_level ); break; case MXLV_LHD_STATUS: if ( (strcmp("clients", list_head->status) == 0) || (strcmp("users", list_head->status) == 0) ) { if ( list_head->is_server ) { mx_status = mx_list_head_print_clients( list_head ); } else { return mx_error( MXE_ILLEGAL_ARGUMENT, fname, "This process is not currently functioning as an active MX server." ); } } else if (strcmp("cpu_type", list_head->status) == 0) { mx_status = mx_list_head_show_cpu_type( list_head ); } else if (strcmp("process_memory", list_head->status) == 0) { mx_status = mx_list_head_show_process_memory( list_head ); } else if (strcmp("system_memory", list_head->status) == 0) { mx_status = mx_list_head_show_system_memory( list_head ); } else if (strcmp("clock", list_head->status) == 0) { mx_info( "clock ticks per second = %g", mx_clock_ticks_per_second() ); } else { return mx_error( MXE_ILLEGAL_ARGUMENT, fname, "Unrecognized database status request '%s'", list_head->status ); } break; case MXLV_LHD_REPORT: mx_status = mx_list_head_record_report( list_head ); break; case MXLV_LHD_REPORT_ALL: mx_status = mx_list_head_record_report_all( list_head ); break; case MXLV_LHD_UPDATE_ALL: mx_status = mx_list_head_record_update_all( list_head ); break; case MXLV_LHD_SUMMARY: mx_status = mx_list_head_record_summary( list_head ); break; case MXLV_LHD_SHOW_RECORD_LIST: mx_status = mx_list_head_record_show_record_list( list_head ); break; case MXLV_LHD_FIELDDEF: mx_status = mx_list_head_record_fielddef( list_head ); break; case MXLV_LHD_SHOW_FIELD: mx_status = mx_list_head_record_show_field( list_head ); break; case MXLV_LHD_SHOW_HANDLE: mx_status = mx_list_head_record_show_handle(list_head); break; case MXLV_LHD_SHOW_CALLBACKS: mx_status = mx_list_head_record_show_callbacks( list_head ); break; case MXLV_LHD_SHOW_CALLBACK_ID: mx_status = mx_list_head_record_show_clbk_id( list_head ); break; case MXLV_LHD_SHOW_SOCKET_HANDLERS: mx_status = mx_list_head_record_show_socket_handlers( list_head ); break; case MXLV_LHD_SHOW_SOCKET_ID: mx_status = mx_list_head_record_show_socket_id( list_head ); break; case MXLV_LHD_VM_REGION: return mx_error( MXE_UNSUPPORTED, fname, "This feature currently does not work." ); #if 0 fprintf( stderr, (void *) list_head->vm_region[0], list_head->vm_region[1] ); #endif break; case MXLV_LHD_BREAKPOINT: if ( list_head->remote_breakpoint_enabled ) { mx_breakpoint(); } else { mx_warning( "Request for remote breakpoint ignored." ); } break; case MXLV_LHD_CRASH: if ( list_head->remote_breakpoint_enabled ) { /* Cause a segmentation fault by * dereferencing a NULL pointer. */ int *crash; crash = NULL; *crash = 1 + *crash; } else { mx_warning( "Request for remote crash ignored." ); } break; case MXLV_LHD_BREAKPOINT_NUMBER: break; case MXLV_LHD_NUMBERED_BREAKPOINT_STATUS: if ( list_head->remote_breakpoint_enabled ) { mx_set_numbered_breakpoint( list_head->breakpoint_number, list_head->numbered_breakpoint_status ); } else { mx_warning( "Request for numbered breakpoint " "change ignored." ); } break; case MXLV_LHD_DEBUGGER_STARTED: if ( list_head->debugger_started ) { mx_set_debugger_started_flag( 1 ); } else { mx_set_debugger_started_flag( 0 ); } break; case MXLV_LHD_SHOW_OPEN_FDS: mx_info( "Open file descriptors:" ); mx_show_fd_names( mx_process_id() ); #if defined(OS_WIN32) mx_info( "Open sockets:" ); mx_win32_show_socket_names(); #endif break; case MXLV_LHD_SHORT_ERROR_CODES: if ( socket_handler != (MX_SOCKET_HANDLER *) NULL ) { socket_handler->short_error_codes = list_head->short_error_codes; } break; case MXLV_LHD_CALLBACKS_ENABLED: /* Nothing to do here. */ break; default: MX_DEBUG( 1,( "%s: *** Unknown MX_PROCESS_PUT label value = %ld", fname, record_field->label_value)); break; } break; default: return mx_error( MXE_ILLEGAL_ARGUMENT, fname, "Unknown operation code = %d", operation ); } return mx_status; }
mx_status_type mx_list_head_show_cpu_type( MX_LIST_HEAD *list_head ) { char architecture_type[80]; char architecture_subtype[80]; char buffer[80]; unsigned long byteorder; mx_status_type mx_status; mx_info( "Computer '%s':", list_head->hostname ); mx_status = mx_get_os_version_string( buffer, sizeof(buffer) ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; mx_info( " OS version = '%s'", buffer ); mx_status = mx_get_cpu_architecture( architecture_type, sizeof(architecture_type), architecture_subtype, sizeof(architecture_subtype) ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; if ( strlen(architecture_subtype) > 0 ) { mx_info( " CPU type = '%s', subtype = '%s'", architecture_type, architecture_subtype ); } else { mx_info( " CPU type = '%s'", architecture_type ); } byteorder = mx_native_byteorder(); switch( byteorder ) { case MX_DATAFMT_BIG_ENDIAN: snprintf( buffer, sizeof(buffer), " %d-bit big-endian computer", MX_WORDSIZE ); break; case MX_DATAFMT_LITTLE_ENDIAN: #if ( defined(OS_WIN32) && (MX_PROGRAM_MODEL == MX_PROGRAM_MODEL_LLP64) ) snprintf( buffer, sizeof(buffer), " 64-bit little-endian computer" ); #else snprintf( buffer, sizeof(buffer), " %d-bit little-endian computer", MX_WORDSIZE ); #endif break; default: snprintf( buffer, sizeof(buffer), " %d-bit unknown-endian computer", MX_WORDSIZE ); break; } mx_info( "%s", buffer ); #if ( MX_PROGRAM_MODEL == MX_PROGRAM_MODEL_LP32 ) mx_info( " Program model = LP32 (16-bit int, 32-bit long, 32-bit ptr)" ); #elif ( MX_PROGRAM_MODEL == MX_PROGRAM_MODEL_ILP32 ) mx_info( " Program model = ILP32 (32-bit int, 32-bit long, 32-bit ptr)" ); #elif ( MX_PROGRAM_MODEL == MX_PROGRAM_MODEL_LLP64 ) mx_info( " Program model = LLP64 (32-bit int, 32-bit long, 64-bit ptr)" ); #elif ( MX_PROGRAM_MODEL == MX_PROGRAM_MODEL_LP64 ) mx_info( " Program model = LP64 (32-bit int, 64-bit long, 64-bit ptr)" ); #elif ( MX_PROGRAM_MODEL == MX_PROGRAM_MODEL_ILP64 ) mx_info( " Program model = ILP64 (64-bit int, 64-bit long, 64-bit ptr)" ); #elif ( MX_PROGRAM_MODEL == MX_PROGRAM_MODEL_UNKNOWN ) mx_info( " Program model = unknown" ); #else mx_info( " Program model = %#x (unrecognized value)", MX_PROGRAM_MODEL ); #endif return MX_SUCCESSFUL_RESULT; }
MX_EXPORT mx_status_type mxd_bluice_area_detector_finish_delayed_initialization( MX_RECORD *record ) { static const char fname[] = "mxd_bluice_area_detector_finish_delayed_initialization()"; MX_AREA_DETECTOR *ad; MX_BLUICE_AREA_DETECTOR *bluice_area_detector; MX_BLUICE_SERVER *bluice_server; MX_BLUICE_FOREIGN_DEVICE *detector_type_string; char collect_name[MXU_BLUICE_NAME_LENGTH+1]; char *detector_type; char *source_ptr, *dest_ptr, *ptr; unsigned long flags; mx_status_type mx_status; if ( record == (MX_RECORD *) NULL ) { return mx_error( MXE_NULL_ARGUMENT, fname, "The MX_RECORD pointer passed was NULL." ); } ad = (MX_AREA_DETECTOR *) record->record_class_struct; mx_status = mxd_bluice_area_detector_get_pointers( ad, &bluice_area_detector, &bluice_server, NULL, fname ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; #if MXD_BLUICE_AREA_DETECTOR_DEBUG MX_DEBUG(-2,("%s invoked for record '%s'", fname, record->name)); #endif /* Find the collect operation. */ switch( record->mx_type ) { case MXT_AD_BLUICE_DCSS: strlcpy( collect_name, "collectFrame", sizeof(collect_name) ); break; case MXT_AD_BLUICE_DHS: strlcpy( collect_name, "detector_collect_image", sizeof(collect_name) ); break; } mx_status = mx_bluice_get_device_pointer( bluice_server, collect_name, bluice_server->operation_array, bluice_server->num_operations, &(bluice_area_detector->collect_operation) ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; bluice_area_detector->last_collect_operation_state = bluice_area_detector->collect_operation->u.operation.operation_state; /* Find the detector stop operation. */ mx_status = mx_bluice_get_device_pointer( bluice_server, "detector_stop", bluice_server->operation_array, bluice_server->num_operations, &(bluice_area_detector->stop_operation) ); if ( mx_status.code != MXE_SUCCESS ) { mx_warning( "detector_stop operation not configured " "by Blu-Ice server '%s'", bluice_server->record->name ); } /* For the bluice_dhs_area_detector driver, we must also find the * transfer image, oscillation ready, and reset run operations. */ if ( record->mx_type == MXT_AD_BLUICE_DHS ) { mx_status = mx_bluice_get_device_pointer( bluice_server, "detector_transfer_image", bluice_server->operation_array, bluice_server->num_operations, &(bluice_area_detector->transfer_operation) ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; mx_status = mx_bluice_get_device_pointer( bluice_server, "detector_oscillation_ready", bluice_server->operation_array, bluice_server->num_operations, &(bluice_area_detector->oscillation_ready_operation) ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; mx_status = mx_bluice_get_device_pointer( bluice_server, "detector_reset_run", bluice_server->operation_array, bluice_server->num_operations, &(bluice_area_detector->reset_run_operation) ); if ( mx_status.code != MXE_SUCCESS ) return mx_status; } #if MXD_BLUICE_AREA_DETECTOR_DEBUG MX_DEBUG(-2,("%s: collect_operation = %p", fname, bluice_area_detector->collect_operation)); MX_DEBUG(-2,("%s: transfer_operation = %p", fname, bluice_area_detector->transfer_operation)); MX_DEBUG(-2,("%s: oscillation_ready_operation = %p", fname, bluice_area_detector->oscillation_ready_operation)); MX_DEBUG(-2,("%s: stop_operation = %p", fname, bluice_area_detector->stop_operation)); MX_DEBUG(-2,("%s: reset_run_operation = %p", fname, bluice_area_detector->reset_run_operation)); #endif /* Find the string containing the filename of the most recently * collected image. */ mx_status = mx_bluice_get_device_pointer( bluice_server, "lastImageCollected", bluice_server->string_array, bluice_server->num_strings, &(bluice_area_detector->last_image_collected_string) ); if ( mx_status.code != MXE_SUCCESS ) { mx_warning( "lastImageCollected string not configured " "by Blu-Ice server '%s'", bluice_server->record->name ); } #if MXD_BLUICE_AREA_DETECTOR_DEBUG MX_DEBUG(-2,("%s: last_image_collected_string = %p", fname, bluice_area_detector->last_image_collected_string)); #endif /* See if a string called 'detectorType' has been sent to us. * If it does exist, then we can figure out what the format of * the detector's image frames are. */ mx_status = mx_bluice_get_device_pointer( bluice_server, "detectorType", bluice_server->string_array, bluice_server->num_strings, &detector_type_string ); if ( mx_status.code != MXE_SUCCESS ) { mx_warning( "detectorType string not configured " "by Blu-Ice server '%s'", bluice_server->record->name ); } if ( (detector_type_string != NULL) && (detector_type_string->foreign_type == MXT_BLUICE_FOREIGN_STRING) && (detector_type_string->u.string.string_buffer != NULL) ) { /* Skip over a leading '{' character if present. */ source_ptr = detector_type_string->u.string.string_buffer; if ( *source_ptr == '{' ) { source_ptr++; } /* Copy the detector type. */ strlcpy( bluice_area_detector->detector_type, source_ptr, sizeof(bluice_area_detector->detector_type) ); /* Delete a trailing '}' and/or newline if present. */ dest_ptr = bluice_area_detector->detector_type; ptr = strrchr( dest_ptr, '}' ); if ( ptr != NULL ) { *ptr = '\0'; } else { ptr = strrchr( dest_ptr, '\n' ); if ( ptr != NULL ) { *ptr = '\0'; } } } else { bluice_area_detector->detector_type[0] = '\0'; } #if MXD_BLUICE_AREA_DETECTOR_DEBUG MX_DEBUG(-2,("%s: Blu-Ice area detector '%s' has detector type '%s'.", fname, record->name, bluice_area_detector->detector_type)); #endif /* Initialize MX_AREA_DETECTOR parameters depending on the * detector type. * * FIXME: Some of this stuff is sure to be wrong. */ ad->binsize[0] = 1; ad->binsize[1] = 1; detector_type = bluice_area_detector->detector_type; if ( detector_type[0] == '\0' ) { ad->datafile_load_format = MXT_IMAGE_FILE_SMV; mx_warning( "No detector type was received from Blu-Ice " "server '%s', so the image format is assumed to be SMV.", bluice_server->record->name ); ad->framesize[0] = 4096; ad->framesize[1] = 4096; } else if ( strcmp(detector_type, "MAR345") == 0 ) { #if 0 ad->datafile_load_format = MXT_IMAGE_FILE_TIFF; #else ad->datafile_load_format = MXT_IMAGE_FILE_SMV; mx_info( "%s: FIXME: MAR345 image type has been forced to SMV.", fname ); #endif ad->framesize[0] = 4096; ad->framesize[1] = 4096; } else { ad->datafile_load_format = MXT_IMAGE_FILE_SMV; mx_warning( "Unrecognized detector type '%s' was reported " "by Blu-Ice area detector '%s'. The image format is " "assumed to be SMV.", detector_type, bluice_server->record->name ); ad->framesize[0] = 4096; ad->framesize[1] = 4096; } ad->image_format = MXT_IMAGE_FORMAT_GREY16; ad->byte_order = (long) mx_native_byteorder(); ad->header_length = MXT_IMAGE_HEADER_LENGTH_IN_BYTES; ad->bytes_per_pixel = 2; ad->bits_per_pixel = 16; ad->bytes_per_frame = mx_round( ad->framesize[0] * ad->framesize[1] * ad->bytes_per_pixel ); ad->maximum_framesize[0] = ad->framesize[0]; ad->maximum_framesize[1] = ad->framesize[1]; ad->binsize[0] = 1; ad->binsize[1] = 1; /* See if the user has requested the loading or saving of * image frames by MX. */ flags = ad->area_detector_flags; if ( flags & MXF_AD_SAVE_FRAME_AFTER_ACQUISITION ) { ad->area_detector_flags &= (~MXF_AD_SAVE_FRAME_AFTER_ACQUISITION); (void) mx_error( MXE_UNSUPPORTED, fname, "Automatic saving of image frames for Blu-Ice " "area detector '%s' is not supported, since the image " "frame data only exists in remote Blu-Ice server '%s'. " "The save frame flag has been turned off.", record->name, bluice_server->record->name ); } bluice_area_detector->initialize_datafile_number = TRUE; MX_DEBUG(-2,("%s complete.", fname)); return mx_status; }
MX_EXPORT int mx_heap_check( unsigned long heap_flags ) { static const char fname[] = "mx_heap_check()"; DWORD number_of_heaps; DWORD maximum_number_of_heaps; HANDLE heap_handle_array[100]; HANDLE heap_handle; BOOL validate_status; int heap_ok; unsigned long i; /* This implementation does not call GetProcessHeaps() in a loop * to resize heap_handle_array to the right size, since this will * result in an infinite loop if mx_heap_check() is called from * within any of the mx_win32_... allocation functions. So we * use a fixed array instead which is probably large enough. */ static const char getprocessheaps_error[] = "ERROR: A call to GetProcessHeaps() failed.\n"; static const char toomanyheaps_error[] = "ERROR: Too many heaps reported by GetProcessHeaps(). " "Increase the size of heap_handle_array and recompile MX " "to fix this.\n"; maximum_number_of_heaps = sizeof( heap_handle_array ) / sizeof( heap_handle_array[0] ); number_of_heaps = GetProcessHeaps( maximum_number_of_heaps, heap_handle_array ); if ( number_of_heaps == 0 ) { write(2, getprocessheaps_error, sizeof(getprocessheaps_error)); } if ( number_of_heaps > maximum_number_of_heaps ) { write(2, toomanyheaps_error, sizeof(toomanyheaps_error)); return FALSE; } heap_ok = TRUE; for ( i = 0; i < number_of_heaps; i++ ) { heap_handle = heap_handle_array[i]; validate_status = HeapValidate( heap_handle, 0, 0 ); if ( validate_status == 0 ) { if ( heap_flags & MXF_HEAP_CHECK_CORRUPTED_VERBOSE ) { #if defined(_WIN64) mx_warning( "%s: Heap %lu (%#I64x) is CORRUPTED.", fname, i, (uint64_t) heap_handle ); #else mx_warning( "%s: Heap %lu (%#lx) is CORRUPTED.", fname, i, (unsigned long) heap_handle ); #endif } heap_ok = FALSE; } else { if ( heap_flags & MXF_HEAP_CHECK_OK_VERBOSE ) { #if defined(_WIN64) mx_info( "%s: Heap %lu (%#I64x) is OK.", fname, i, (uint64_t) heap_handle ); #else mx_info( "%s: Heap %lu (%#lx) is OK.", fname, i, (unsigned long) heap_handle ); #endif } } } if ( heap_ok ) { if ( heap_flags & MXF_HEAP_CHECK_OK ) { mx_info( "%s: Heap is OK", fname ); } } else { if ( heap_flags & MXF_HEAP_CHECK_CORRUPTED ) { mx_warning("%s: Heap is corrupted.", fname); } } if ( heap_flags & MXF_HEAP_CHECK_STACK_TRACEBACK ) { mx_stack_traceback(); } return heap_ok; }