Skip to content

Commit

Permalink
fix a deadlock bug: #83
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentWei committed Mar 21, 2022
1 parent abeafa3 commit 2e8eba7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/include/dc.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ typedef struct tagDC* PDC;
# else /* not defined _MGSCHEMA_COMPOSITING */
void __mg_lock_recalc_gcrinfo (PDC pdc);
void __mg_unlock_gcrinfo (PDC pdc);
#define LOCK_GCRINFO(pdc) __mg_lock_recalc_gcrinfo (pdc)
#define LOCK_GCRINFO(pdc) if (dc_IsGeneralDC(pdc)) __mg_lock_recalc_gcrinfo (pdc)
#define UNLOCK_GCRINFO(pdc) if (dc_IsGeneralDC(pdc)) __mg_unlock_gcrinfo (pdc)
# endif /* not defined _MGSCHEMA_COMPOSITING */

Expand Down
4 changes: 2 additions & 2 deletions src/kernel/desktop-comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ static LRESULT WindowMessageHandler(UINT message, PMAINWIN pWin, LPARAM lParam)
else {
from = 0;
}

lock_zi_for_read (zi);

from = __kernel_get_next_znode (zi, from);
Expand Down Expand Up @@ -1821,7 +1821,7 @@ static void dskRefreshAllWindow (const RECT* invrc)
info.is_empty_invrc = TRUE;

#ifdef _MGHAVE_MENU
dskForceCloseMenu ();
dskForceCloseMenu ();
#endif

SendMessage (HWND_DESKTOP, MSG_ERASEDESKTOP, 0,
Expand Down
12 changes: 8 additions & 4 deletions src/kernel/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,11 @@ static inline void unlock_zi_for_change (const ZORDERINFO* zi)

static inline void lock_zi_for_read (const ZORDERINFO* zi)
{
pthread_rwlock_rdlock(&((ZORDERINFO*)zi)->rwlock);
if (pthread_rwlock_rdlock(&((ZORDERINFO*)zi)->rwlock)) {
_ERR_PRINTF("Failed pthread_rwlock_rdlock: %s (%d)\n",
strerror(errno), errno);
abort();
}
}

static inline void unlock_zi_for_read (const ZORDERINFO* zi)
Expand Down Expand Up @@ -3641,6 +3645,9 @@ static int dskMoveWindow (int cli, int idx_znode, HDC memdc, const RECT* rcWin)

do_for_all_znodes (&rcOld, zi, _cb_update_znode, ZT_ALL);

/* unlock zi for change ... */
unlock_zi_for_change (zi);

if (nodes [0].flags & ZOF_IF_REFERENCE) {
SendMessage (HWND_DESKTOP,
MSG_ERASEDESKTOP, 0, (LPARAM)&rcOld);
Expand Down Expand Up @@ -3680,9 +3687,6 @@ static int dskMoveWindow (int cli, int idx_znode, HDC memdc, const RECT* rcWin)

update_client_window_rgn (nodes [idx_znode].cli,
nodes [idx_znode].hwnd);

/* unlock zi for change ... */
unlock_zi_for_change (zi);
}
else {
lock_zi_for_change (zi);
Expand Down
2 changes: 0 additions & 2 deletions src/newgdi/gdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4349,8 +4349,6 @@ static void on_surface_changed_for_control (struct _travel_context* ctxt,
RECT rc_surface, rc_minimal;
PDC pdc = dc_HDC2PDC (ctrl->privCDC);

_WRN_PRINTF ("called\n");

pdc->surface = ctxt->surface;

if (pdc->surface != __gal_screen) {
Expand Down

3 comments on commit 2e8eba7

@htk719809837
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好,我现在按照这个更新了以后,发现这个死锁还是没有解开,出现在对整个对话框使用movewindow进行移动后,在创建新的对话框时,程序报错,lock_zi_for_read: Failed pthread_rwlock_rdlock: No such file or directory (2),但是做一个风险操作,去掉 unlock_zi_for_change (zi); 可以使程序正常运行,希望能够尽快修复。

@VincentWei
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug may have been fixed in rel-5-0 branch. You can try the latest code in rel-5-0 branch.

If it is fixed, I will merge rel-5-0 to master.

Thank you in advance!

@htk719809837
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在 关于一个死锁问题 #87 中似乎并没有被修复

Please sign in to comment.