Changeset 523ef308d2bff928d1246e968003a3ff429890db
- Timestamp:
- 28/05/08 21:32:25 (4 months ago)
- git-parent:
- Files:
-
- src/libvlc.h (modified) (1 diff)
- src/misc/objects.c (modified) (1 diff)
- src/misc/variables.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/libvlc.h
r1746fdd r523ef30 47 47 void vlc_threads_end( void ); 48 48 vlc_object_t *vlc_threadobj (void); 49 #ifndef NDEBUG 50 void vlc_refcheck (vlc_object_t *obj); 51 #else 52 # define vlc_refcheck( obj ) (void)0 53 #endif 49 54 50 55 /* src/misc/objects.c
r1746fdd r523ef30 1470 1470 } 1471 1471 } 1472 1473 #ifndef NDEBUG 1474 void vlc_refcheck (vlc_object_t *obj) 1475 { 1476 static unsigned errors = 0; 1477 vlc_object_t *caller = vlc_threadobj (); 1478 vlc_object_internals_t *priv = vlc_internals (obj); 1479 int refs; 1480 1481 if (errors > 100) 1482 return; 1483 1484 if (!caller) 1485 return; /* main thread, not sure how to handle it */ 1486 1487 /* An object can always access itself without reference! */ 1488 if (caller == obj) 1489 return; 1490 1491 /* The calling thread is younger than the object. 1492 * Access could be valid, we would need more accounting. */ 1493 if (caller->i_object_id > obj->i_object_id) 1494 return; 1495 1496 vlc_spin_lock (&priv->ref_spin); 1497 refs = priv->i_refcount; 1498 vlc_spin_unlock (&priv->ref_spin); 1499 1500 /* Object has more than one reference. 1501 * The current thread could be holding a valid reference. */ 1502 if (refs > 1) 1503 return; 1504 1505 /* The parent of an object normally holds the unique reference. 1506 * As not all objects are threads, it could also be an ancestor. */ 1507 vlc_mutex_lock (&structure_lock); 1508 for (vlc_object_t *cur = obj; cur != NULL; cur = cur->p_parent) 1509 if (cur == caller) 1510 { 1511 vlc_mutex_unlock (&structure_lock); 1512 return; 1513 } 1514 vlc_mutex_unlock (&structure_lock); 1515 1516 #if 1 1517 if (caller->i_object_type == VLC_OBJECT_PLAYLIST) 1518 return; /* Playlist is too clever, or hopelessly broken. */ 1519 #endif 1520 msg_Err (caller, "This thread is accessing..."); 1521 msg_Err (obj, "...this object in a suspicious manner."); 1522 1523 if (++errors == 100) 1524 msg_Err (caller, "Too many reference errors"); 1525 } 1526 #endif src/misc/variables.c
r2f601f6 r523ef30 169 169 vlc_object_internals_t *p_priv = vlc_internals( p_this ); 170 170 171 vlc_refcheck( p_this ); 171 172 vlc_mutex_lock( &p_priv->var_lock ); 172 173 … … 332 333 vlc_object_internals_t *p_priv = vlc_internals( p_this ); 333 334 335 vlc_refcheck( p_this ); 334 336 vlc_mutex_lock( &p_priv->var_lock ); 335 337 … … 408 410 vlc_object_internals_t *p_priv = vlc_internals( p_this ); 409 411 412 vlc_refcheck( p_this ); 410 413 vlc_mutex_lock( &p_priv->var_lock ); 411 414 … … 760 763 vlc_object_internals_t *p_priv = vlc_internals( p_this ); 761 764 765 vlc_refcheck( p_this ); 762 766 vlc_mutex_lock( &p_priv->var_lock ); 763 767 … … 837 841 vlc_object_internals_t *p_priv = vlc_internals( p_this ); 838 842 843 vlc_refcheck( p_this ); 839 844 vlc_mutex_lock( &p_priv->var_lock ); 840 845 … … 903 908 vlc_object_internals_t *p_priv = vlc_internals( p_this ); 904 909 910 vlc_refcheck( p_this ); 905 911 entry.pf_callback = pf_callback; 906 912 entry.p_data = p_data; … … 940 946 vlc_object_internals_t *p_priv = vlc_internals( p_this ); 941 947 948 vlc_refcheck( p_this ); 942 949 vlc_mutex_lock( &p_priv->var_lock ); 943 950 … … 1576 1583 } 1577 1584 1585 vlc_refcheck( p_this ); 1578 1586 i_type = var_Type( p_obj, psz_cmd ); 1579 1587 if( !( i_type&VLC_VAR_ISCOMMAND ) )
