From def29ab92abad0fa4e97f83dd004d956c4327446 Mon Sep 17 00:00:00 2001 From: GiWoong Kim Date: Mon, 4 Nov 2013 12:06:47 +0900 Subject: [PATCH] display, skin: remove some warnings 1. added null pointer check 2. added unlock for exceptional path (maru_sdl.c) 3. added title for boilerplate (CustomScrollBar, CustomScrollBarComposite, CustomScrollBarCompositeLayout.java) 4. define socket macro (maruskin_server.c) 5. minor modification, etc Change-Id: Ibf79e407d259366c72b5f7b35e400694e276fb08 Signed-off-by: GiWoong Kim --- tizen/src/debug_ch.c | 4 +- tizen/src/maru_finger.c | 9 +- tizen/src/maru_sdl.c | 15 ++- .../tizen/emulator/skin/EmulatorFingers.java | 2 +- .../tizen/emulator/skin/EmulatorSdlSkin.java | 12 +- .../skin/comm/sock/SocketCommunicator.java | 26 ++--- .../emulator/skin/custom/CustomScrollBar.java | 10 +- .../skin/custom/CustomScrolledComposite.java | 2 +- .../custom/CustomScrolledCompositeLayout.java | 2 +- .../skin/custom/SpecialKeyWindow.java | 12 +- .../image/GeneralKeyWindowImageRegistry.java | 4 +- .../skin/image/GeneralSkinImageRegistry.java | 4 +- .../emulator/skin/image/ImageRegistry.java | 4 +- .../skin/image/ProfileSkinImageRegistry.java | 4 +- .../image/SpecialKeyWindowImageRegistry.java | 4 +- .../tizen/emulator/skin/log/SkinLogger.java | 6 +- .../emulator/skin/menu/KeyWindowKeeper.java | 37 +++--- tizen/src/skin/maruskin_server.c | 106 +++++++----------- 18 files changed, 126 insertions(+), 137 deletions(-) diff --git a/tizen/src/debug_ch.c b/tizen/src/debug_ch.c index b794fb636a..833b1ec357 100644 --- a/tizen/src/debug_ch.c +++ b/tizen/src/debug_ch.c @@ -481,9 +481,9 @@ int dbg_log(enum _debug_class cls, struct _debug_channel *channel, buf_time, debug_classes[cls], channel->name); if (*channel->multiname) { - ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, ":%s]", channel->multiname); + ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, ":%s] ", channel->multiname); } else { - ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, "]"); + ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, "] "); } va_start(valist, format); diff --git a/tizen/src/maru_finger.c b/tizen/src/maru_finger.c index 975feb05a7..669e3fbd47 100644 --- a/tizen/src/maru_finger.c +++ b/tizen/src/maru_finger.c @@ -186,13 +186,14 @@ void init_multi_touch_state(void) mts->finger_slot = NULL; } mts->finger_slot = - (FingerPoint *)g_malloc0(sizeof(FingerPoint) * mts->finger_cnt_max); + (FingerPoint *) g_malloc0(sizeof(FingerPoint) * mts->finger_cnt_max); for (i = 0; i < mts->finger_cnt_max; i++) { finger = get_finger_point_from_slot(i); - //finger->id = 0; - finger->origin_x = finger->origin_y = -1; - finger->x = finger->y = -1; + if (finger != NULL) { + finger->origin_x = finger->origin_y = -1; + finger->x = finger->y = -1; + } } mts->finger_point_size = DEFAULT_FINGER_POINT_SIZE; diff --git a/tizen/src/maru_sdl.c b/tizen/src/maru_sdl.c index 80ab8fdb9b..28e4f85539 100644 --- a/tizen/src/maru_sdl.c +++ b/tizen/src/maru_sdl.c @@ -678,13 +678,13 @@ static void maru_sdl_resize_bh(void *opaque) INFO("Set up a video mode with the specified width, " "height and bits-per-pixel\n"); + sdl_alteration = 1; + sdl_skip_update = 0; + #ifdef SDL_THREAD pthread_mutex_lock(&sdl_mutex); #endif - sdl_alteration = 1; - sdl_skip_update = 0; - /* get current setting information and calculate screen size */ display_width = get_emul_lcd_width(); display_height = get_emul_lcd_height(); @@ -720,6 +720,11 @@ static void maru_sdl_resize_bh(void *opaque) ERR("Could not open SDL display (%dx%dx%d) : %s\n", surface_width, surface_height, get_emul_sdl_bpp(), SDL_GetError()); + +#ifdef SDL_THREAD + pthread_mutex_unlock(&sdl_mutex); +#endif + return; } @@ -837,12 +842,12 @@ void maruskin_sdl_quit(void) qemu_bh_delete(sdl_resize_bh); } + sdl_alteration = -1; + #ifdef SDL_THREAD pthread_mutex_lock(&sdl_mutex); #endif - sdl_alteration = -1; - SDL_Quit(); #ifdef SDL_THREAD diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java index 866228bc47..05b21c083d 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java @@ -84,7 +84,7 @@ public class EmulatorFingers { initMultiTouchState(maximum); } - class FingerPoint { + static class FingerPoint { private int id; private int originX; private int originY; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java index 0d90b30032..76375a6eed 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java @@ -66,7 +66,6 @@ public class EmulatorSdlSkin extends EmulatorSkin { /* org.eclipse.swt.widgets.Widget */ if (SwtUtil.isLinuxPlatform()) { - try { Field field = lcdCanvas.getClass().getField("embeddedHandle"); windowHandleId = field.getLong(lcdCanvas); @@ -84,9 +83,7 @@ public class EmulatorSdlSkin extends EmulatorSkin { logger.log(Level.SEVERE, e.getMessage(), e); shutdown(); } - } else if (SwtUtil.isWindowsPlatform()) { - try { Field field = lcdCanvas.getClass().getField("handle"); windowHandleId = field.getLong(lcdCanvas); @@ -104,15 +101,10 @@ public class EmulatorSdlSkin extends EmulatorSkin { logger.log(Level.SEVERE, e.getMessage(), e); shutdown(); } - - } else if (SwtUtil.isMacPlatform()) { - - // not supported - windowHandleId = 0; - } else { + /* not supported */ logger.severe("Not Supported OS platform:" + SWT.getPlatform()); - System.exit(-1); + shutdown(); } return windowHandleId; diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java index 2ead9b2ab4..1b5141118e 100755 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java @@ -65,7 +65,7 @@ import org.tizen.emulator.skin.util.SkinUtil; * */ public class SocketCommunicator implements ICommunicator { - public class DataTranfer { + public static class DataTranfer { private boolean isTransferState; private byte[] receivedData; @@ -572,16 +572,16 @@ public class SocketCommunicator implements ICommunicator { } private void sendToQEMUInternal(SkinSendData sendData) { - try { - if (null == sendData) { - return; - } - - SendCommand command = sendData.getCommand(); - ISendData data = sendData.getSendData(); + if (null == sendData) { + return; + } + + SendCommand command = sendData.getCommand(); + ISendData data = sendData.getSendData(); - reqId = (Integer.MAX_VALUE == reqId) ? 0 : ++reqId; + reqId = (Integer.MAX_VALUE == reqId) ? 0 : ++reqId; + try { dataOutputStream.writeInt(uId); dataOutputStream.writeInt(reqId); dataOutputStream.writeShort(command.value()); @@ -615,11 +615,9 @@ public class SocketCommunicator implements ICommunicator { logger.fine("[Socket] data - " + data.toString()); } } - } catch (IOException e) { logger.log(Level.SEVERE, e.getMessage(), e); } - } public byte[] getReceivedData(DataTranfer dataTranfer) { @@ -714,10 +712,8 @@ public class SocketCommunicator implements ICommunicator { isTerminated = true; - if (null != sendQueue) { - synchronized (sendQueue) { - sendQueue.notifyAll(); - } + synchronized (sendQueue) { + sendQueue.notifyAll(); } if (null != heartbeatTimer) { diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java index 93a1708129..dcbd94288c 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java @@ -1,5 +1,5 @@ /** - * + * Custom Scroll Bar * * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved. * @@ -189,9 +189,9 @@ public class CustomScrollBar { /* draw a thumb */ int heightScrollGap = compositeScroll.getMinHeight() - heightScrollBar; - float tempHeightThumb = (compositeScroll.getMinHeight() - heightScrollGap) * + int tempHeightThumb = (compositeScroll.getMinHeight() - heightScrollGap) * dataShaft.heightShaft / compositeScroll.getMinHeight(); - dataThumb.boundsThumb.height = Math.max(1, (int)tempHeightThumb); + dataThumb.boundsThumb.height = Math.max(1, tempHeightThumb); dataThumb.boundsThumb.x = 2; dataThumb.boundsThumb.y = getSelection() * @@ -328,11 +328,11 @@ public class CustomScrollBar { if (dataThumb.isGrabbed == true) { int yDragged = e.y - dataThumb.yGrabPosition; - float yDraggedScale = yDragged * + int yDraggedScale = yDragged * (compositeScroll.getMinHeight() - heightScrollBar) / (dataShaft.heightShaft - dataThumb.boundsThumb.height); - setSelection(dataThumb.yGrabSelection + (int)yDraggedScale); + setSelection(dataThumb.yGrabSelection + yDraggedScale); updateScrollbar(); } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledComposite.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledComposite.java index 870e4b02b5..e4ecec73dd 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledComposite.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledComposite.java @@ -1,5 +1,5 @@ /** - * + * Custom Scrolled Composite * * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved. * diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledCompositeLayout.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledCompositeLayout.java index 6377a53c28..a1f64b79ba 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledCompositeLayout.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledCompositeLayout.java @@ -1,5 +1,5 @@ /** - * + * Custom Scrolled Composite Layout * * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved. * diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java index 40b9fca4d5..46e545ba47 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java @@ -272,22 +272,22 @@ public class SpecialKeyWindow extends SkinWindow { shellMouseMoveListener = new MouseMoveListener() { @Override public void mouseMove(MouseEvent e) { - if (isTouch == true) { + if (isTouch == true) { logger.info("mouseMove in KeyWindow : " + e.x + ", " + e.y); - HWKey pressedHWKey = currentPressedHWKey; + HWKey pressedHWKey = currentPressedHWKey; int x = pressedHWKey.getRegion().x; int y = pressedHWKey.getRegion().y; int width = pressedHWKey.getRegion().width; int height = pressedHWKey.getRegion().height; - int eventType; + //int eventType; if (SkinUtil.isInGeometry(e.x, e.y, x, y, width, height)) { - eventType = MouseEventType.DRAG.value(); + //eventType = MouseEventType.DRAG.value(); } else { isTouch = false; - eventType = MouseEventType.RELEASE.value(); - /* rollback a keyPressed image resion */ + //eventType = MouseEventType.RELEASE.value(); + /* rollback a keyPressed image region */ shell.redraw(x, y, width, height, false); } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java index 7aef8b9121..5c5b4f26da 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java @@ -132,7 +132,9 @@ public class GeneralKeyWindowImageRegistry { while (imageIterator.hasNext()) { image = imageIterator.next(); - image.dispose(); + if (image != null) { + image.dispose(); + } } } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java index 158ce6ccb5..5248adf79d 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java @@ -123,7 +123,9 @@ public class GeneralSkinImageRegistry { while (imageIterator.hasNext()) { image = imageIterator.next(); - image.dispose(); + if (image != null) { + image.dispose(); + } } } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java index 62a1058b3d..d61f9f0f84 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java @@ -224,7 +224,9 @@ public class ImageRegistry { while (imageIterator.hasNext()) { image = imageIterator.next(); - image.dispose(); + if (image != null) { + image.dispose(); + } } } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java index 84e81ac97a..9690504e9c 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java @@ -129,7 +129,9 @@ public class ProfileSkinImageRegistry { while (imageIterator.hasNext()) { image = imageIterator.next(); - image.dispose(); + if (image != null) { + image.dispose(); + } } } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java index adcf4d96a6..dfe5b6f8b8 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java @@ -116,7 +116,9 @@ public class SpecialKeyWindowImageRegistry { while (imageIterator.hasNext()) { image = imageIterator.next(); - image.dispose(); + if (image != null) { + image.dispose(); + } } } } diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java index 2258bea999..a6b066cf19 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java @@ -112,9 +112,11 @@ public class SkinLogger { } File dir = new File(path + LOG_FOLDER); - dir.mkdir(); + if (dir.mkdir() == false) { + /* do nothing */ + } - /* delete .lck files after abnomal skin termination */ + /* delete .lck files after abnormal skin termination */ File[] listFiles = dir.listFiles(); for (File f : listFiles) { String name = f.getName(); diff --git a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java index 66e0e441e9..c4cd21720f 100644 --- a/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java +++ b/tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java @@ -86,7 +86,8 @@ public class KeyWindowKeeper { /* create a Key Window */ determineLayout(); - if (isGeneralKeyWindow() == true) { + if (isGeneralKeyWindow() == true + || skin.getPopupMenu().keyWindowItem.getMenu() == null) { if (imageRegstry == null) { logger.warning("GeneralKeyWindowImageRegistry is null"); return; @@ -96,12 +97,14 @@ public class KeyWindowKeeper { skin.getEmulatorSkinState().getCurrentRotationId()); if (keyMapList == null) { - selectKeyWindowMenu(skin.isKeyWindow = false); logger.info("keyMapList is null"); + + selectKeyWindowMenu(skin.isKeyWindow = false); return; } else if (keyMapList.isEmpty() == true) { - selectKeyWindowMenu(skin.isKeyWindow = false); logger.info("keyMapList is empty"); + + selectKeyWindowMenu(skin.isKeyWindow = false); return; } @@ -196,15 +199,19 @@ public class KeyWindowKeeper { /* for Menu */ public boolean isSelectKeyWindowMenu() { - MenuItem keywindow = skin.getPopupMenu().keyWindowItem; + MenuItem keywindowMenu = skin.getPopupMenu().keyWindowItem; - if (keywindow != null) { + if (keywindowMenu != null) { if (isGeneralKeyWindow() == true) { - return keywindow.getSelection(); + return keywindowMenu.getSelection(); } else { - for (MenuItem layout : keywindow.getMenu().getItems()) { - if (layout.getSelection() == true) { - return true; + if (keywindowMenu.getMenu() == null) { + logger.info("Special KeyWindow menu item is null"); + } else { + for (MenuItem layout : keywindowMenu.getMenu().getItems()) { + if (layout.getSelection() == true) { + return true; + } } } } @@ -214,13 +221,17 @@ public class KeyWindowKeeper { } public void selectKeyWindowMenu(boolean on) { - MenuItem keywindow = skin.getPopupMenu().keyWindowItem; + MenuItem keywindowMenu = skin.getPopupMenu().keyWindowItem; - if (keywindow != null) { + if (keywindowMenu != null) { if (isGeneralKeyWindow() == true) { - keywindow.setSelection(on); + keywindowMenu.setSelection(on); } else { - keywindow.getMenu().getItem(indexLayout).setSelection(on); + if (keywindowMenu.getMenu() == null) { + logger.info("Special KeyWindow menu item is null"); + } else { + keywindowMenu.getMenu().getItem(indexLayout).setSelection(on); + } } } } diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 2a816fe2bb..b04d937366 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -57,13 +57,17 @@ #include #include -#define socket_error() WSAGetLastError() +#define SLEEP(x) Sleep(x) +#define SOCKET_CLOSE(sock) closesocket(sock) +#define SOCKET_ERROR() WSAGetLastError() #else #include #include #include -#define socket_error() errno +#define SLEEP(x) usleep(x * 1000) +#define SOCKET_CLOSE(sock) close(sock) +#define SOCKET_ERROR() errno #endif #include "debug_ch.h" @@ -242,11 +246,8 @@ void shutdown_skin_server(void) INFO("skin client sent normal shutdown response.\n"); break; } else { -#ifdef CONFIG_WIN32 - Sleep(1); /* 1ms */ -#else - usleep(1000); -#endif + SLEEP(1); /* 1ms */ + count++; } } @@ -259,22 +260,16 @@ void shutdown_skin_server(void) is_force_close_client = 1; if (client_sock) { -#ifdef CONFIG_WIN32 - closesocket(client_sock); -#else - close(client_sock); -#endif + SOCKET_CLOSE(client_sock); + client_sock = 0; } if (close_server_socket) { INFO("skin client did not send normal shutdown response.\n"); if (server_sock) { -#ifdef CONFIG_WIN32 - closesocket(server_sock); -#else - close(server_sock); -#endif + SOCKET_CLOSE(server_sock); + server_sock = 0; } } @@ -398,11 +393,7 @@ void notify_booting_progress(unsigned int layer, int progress_value) ERR("fail to send SEND_BOOTING_PROGRESS to skin.\n"); } -#ifdef CONFIG_WIN32 - Sleep(1); /* 1ms */ -#else - usleep(1000); -#endif + SLEEP(1); /* 1ms */ } else { INFO("skin client socket is not connected yet\n"); } @@ -606,11 +597,8 @@ static void* run_skin_server(void* args) perror("skin server bind error : "); if (server_sock) { -#ifdef CONFIG_WIN32 - closesocket(server_sock); -#else - close(server_sock); -#endif + SOCKET_CLOSE(server_sock); + server_sock = 0; } @@ -637,11 +625,8 @@ static void* run_skin_server(void* args) perror("skin_server listen error : "); if (server_sock) { -#ifdef CONFIG_WIN32 - closesocket(server_sock); -#else - close(server_sock); -#endif + SOCKET_CLOSE(server_sock); + server_sock = 0; } @@ -674,6 +659,10 @@ static void* run_skin_server(void* args) } } + if (client_sock != 0) { + SOCKET_CLOSE(client_sock); + } + INFO("start accepting socket...\n"); if (0 > (client_sock = accept( @@ -704,7 +693,7 @@ static void* run_skin_server(void* args) is_force_close_client = 0; } else { ERR("skin_server read error (%d): %d\n", - socket_error(), read_cnt); + SOCKET_ERROR(), read_cnt); perror("skin_server read error : "); } @@ -1088,36 +1077,31 @@ static void* run_skin_server(void* args) break; } case RECV_RESPONSE_SHUTDOWN: { - log_cnt += sprintf( log_buf + log_cnt, "RECV_RESPONSE_SHUTDOWN ==\n" ); - INFO( log_buf ); + log_cnt += sprintf(log_buf + log_cnt, "RECV_RESPONSE_SHUTDOWN ==\n"); + INFO(log_buf); stop_server = 1; break; } default: { - log_cnt += sprintf( log_buf + log_cnt, "!!! unknown command : %d\n", cmd ); - TRACE( log_buf ); + log_cnt += sprintf(log_buf + log_cnt, "!!! unknown command : %d\n", cmd); + TRACE(log_buf); - ERR( "!!! unknown command : %d\n", cmd ); + ERR("!!! unknown command : %d\n", cmd); break; } } - } - } - - } + } /* end of while */ + } /* end of while */ stop_heart_beat(); /* clean up */ if (server_sock) { -#ifdef CONFIG_WIN32 - closesocket(server_sock); -#else - close(server_sock); -#endif + SOCKET_CLOSE(server_sock); + server_sock = 0; } @@ -1298,17 +1282,9 @@ static void* do_heart_beat(void* args) if (booting_handicap_cnt < 5) { booting_handicap_cnt++; -#ifdef CONFIG_WIN32 - Sleep(hb_interval * 10); /* 10sec */ -#else - usleep(hb_interval * 1000 * 10); -#endif + SLEEP(hb_interval * 10); /* 10sec */ } else { -#ifdef CONFIG_WIN32 - Sleep(hb_interval); /* 1sec */ -#else - usleep(hb_interval * 1000); -#endif + SLEEP(hb_interval); /* 1sec */ } if (stop_heartbeat) { @@ -1359,22 +1335,16 @@ static void* do_heart_beat(void* args) is_force_close_client = 1; if (client_sock) { -#ifdef CONFIG_WIN32 - closesocket(client_sock); -#else - close(client_sock); -#endif + SOCKET_CLOSE(client_sock); + client_sock = 0; } stop_server = 1; if (server_sock) { -#ifdef CONFIG_WIN32 - closesocket(server_sock); -#else - close(server_sock); -#endif + SOCKET_CLOSE(server_sock); + server_sock = 0; } @@ -1409,5 +1379,7 @@ static int start_heart_beat(void) static void stop_heart_beat(void) { + INFO("stop the heart beat signal\n"); + stop_heartbeat = 1; } -- 2.34.1