mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 13:25:45 +02:00
bytevector: don't deadlock on operator<<
operator<< was a friend class that locked the ByteVector, then invoked hexdump on the bytevector, which used ByteVector::operator[]...which locked the ByteVector, resulting in a deadlock. operator<< shouldn't be a friend class anyway. Make hexdump use the normal public access methods for ByteVector. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
3e89fe34ed
commit
e99a505b3b
@ -55,7 +55,6 @@ namespace crucible {
|
||||
Pointer m_ptr;
|
||||
size_t m_size = 0;
|
||||
mutable mutex m_mutex;
|
||||
friend ostream & operator<<(ostream &os, const ByteVector &bv);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@ -74,6 +73,8 @@ namespace crucible {
|
||||
THROW_CHECK2(out_of_range, size(), sizeof(T), size() >= sizeof(T));
|
||||
return reinterpret_cast<T*>(data());
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream &os, const ByteVector &bv);
|
||||
}
|
||||
|
||||
#endif // _CRUCIBLE_BYTEVECTOR_H_
|
||||
|
@ -183,7 +183,6 @@ namespace crucible {
|
||||
|
||||
ostream&
|
||||
operator<<(ostream &os, const ByteVector &bv) {
|
||||
unique_lock<mutex> lock(bv.m_mutex);
|
||||
hexdump(os, bv);
|
||||
return os;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user