If owner of gbufmgr fd isn't frontend, don't dup2 fd 91/57491/1 accepted/tizen/mobile/20160122.032757 accepted/tizen/tv/20160122.032907 accepted/tizen/wearable/20160122.032953 submit/tizen/20160121.044811
authorChangyeon Lee <cyeon.lee@samsung.com>
Wed, 20 Jan 2016 11:15:27 +0000 (20:15 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Wed, 20 Jan 2016 11:26:30 +0000 (20:26 +0900)
Change-Id: I320b65e8f029bc99ca2dba55fb6eb82632369934
Signed-off-by: Changyeon Lee <cyeon.lee@samsung.com>
src/tbm_bufmgr.c

index 90944a9..1c76a93 100755 (executable)
@@ -817,17 +817,18 @@ tbm_bufmgr tbm_bufmgr_init(int fd)
        /* initialize buffer manager */
        if (gBufMgr) {
                DBG("[libtbm:%d] use previous gBufMgr\n", getpid());
-
-               if (fd >= 0) {
-                       if (dup2(gBufMgr->fd, fd) < 0) {
-                               _tbm_set_last_result(TBM_BO_ERROR_DUP_FD_FAILED);
-                               DBG("[libtbm:%d] Fail to duplicate(dup2) the drm fd\n",
-                                       getpid());
-                               pthread_mutex_unlock(&gLock);
-                               return NULL;
+               if (!gBufMgr->fd_flag) {
+                       if (fd >= 0) {
+                               if (dup2(gBufMgr->fd, fd) < 0) {
+                                       _tbm_set_last_result(TBM_BO_ERROR_DUP_FD_FAILED);
+                                       TBM_LOG("[libtbm:%d] Fail to duplicate(dup2) the drm fd\n",
+                                               getpid());
+                                       pthread_mutex_unlock(&gLock);
+                                       return NULL;
+                               }
+                               DBG("[libtbm:%d] duplicate the drm_fd(%d), new drm_fd(%d).\n",
+                                       getpid(), gBufMgr->fd, fd);
                        }
-                       DBG("[libtbm:%d] duplicate the drm_fd(%d), new drm_fd(%d).\n",
-                               getpid(), gBufMgr->fd, fd);
                }
                gBufMgr->ref_count++;