Skip to content

Commit

Permalink
add silly logs to confirm issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
fulara committed Jan 18, 2022
1 parent f985535 commit 186f615
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
21 changes: 10 additions & 11 deletions src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,7 @@ use mysql_common::{
packets::SslRequest,
};

use std::{
borrow::{Borrow, Cow},
cmp,
collections::HashMap,
convert::TryFrom,
io::{self, Write as _},
mem,
ops::{Deref, DerefMut},
process,
sync::Arc,
};
use std::{borrow::{Borrow, Cow}, cmp, collections::HashMap, convert::TryFrom, io::{self, Write as _}, mem, ops::{Deref, DerefMut}, process, sync::Arc, thread};

use crate::{
buffer_pool::{get_buffer, Buffer},
Expand All @@ -63,6 +53,7 @@ use crate::{
LocalInfileHandler, Opts, OptsBuilder, Params, QueryResult, Result, Transaction,
Value::{self, Bytes, NULL},
};
use crate::conn::query_result::log_it;

use crate::DriverError::TlsNotSupported;
use crate::SslOpts;
Expand Down Expand Up @@ -911,7 +902,15 @@ impl Conn {
self.sync_seq_id();
}

if log_it() {
println!("{:?} Reading a packet....", thread::current().id());
}
let pld = self.read_packet()?;

if log_it() {
println!("{:?} Okay packet read.... {:#X}", thread::current().id(), pld[0]);
}

match pld[0] {
0x00 => {
let ok = self.handle_ok::<CommonOkPacket>(&pld)?;
Expand Down
34 changes: 30 additions & 4 deletions src/conn/query_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub use mysql_common::proto::{Binary, Text};

use mysql_common::packets::OkPacket;

use std::{borrow::Cow, marker::PhantomData, sync::Arc};
use std::{borrow::Cow, marker::PhantomData, sync::Arc, thread};

use crate::{conn::ConnMut, Column, Conn, Error, Result, Row};

Expand Down Expand Up @@ -97,6 +97,10 @@ impl From<Or<Vec<Column>, OkPacket<'static>>> for SetIteratorState {
}
}

pub fn log_it() -> bool {
std::path::Path::new("/tmp/log").exists()
}

/// Response to a query or statement execution.
///
/// It is an iterator:
Expand Down Expand Up @@ -141,10 +145,25 @@ impl<'c, 't, 'tc, T: crate::prelude::Protocol> QueryResult<'c, 't, 'tc, T> {
"self.state != OnBoundary"
);

if log_it() {
println!("{:?} Loggin! state: {:?} index {:?}, conn: {:?} more result exist?! {}", thread::current().id(), self.state, self.set_index, self.conn, self.conn.more_results_exists());
}

if self.conn.more_results_exists() {
match self.conn.handle_result_set() {
Ok(meta) => self.state = meta.into(),
Err(err) => self.state = err.into(),
Ok(meta) => {
self.state = meta.into();
if log_it() {
println!("{:?} Loggin! Entered Ok State. now: {:?}, index b4 incrementing {}", thread::current().id(), self.state, self.set_index);
}
},
Err(err) => {
let err_s = format!("{:?}", err);
self.state = err.into();
if log_it() {
println!("{:?} Loggin! Entered err state. now: {:?}, index b4 incrementing {}. err is: {}", thread::current().id(), self.state, self.set_index, err_s);
}
},
}
self.set_index += 1;
} else {
Expand Down Expand Up @@ -217,6 +236,9 @@ impl<'c, 't, 'tc, T: crate::prelude::Protocol> QueryResult<'c, 't, 'tc, T> {
pub fn iter<'d>(&'d mut self) -> Option<ResultSet<'c, 't, 'tc, 'd, T>> {
use SetIteratorState::*;

if log_it() {
println!("{:?} Loggin! state: in ::iter() {:?}", thread::current().id(), self.state);
}
if let OnBoundary | Done = &self.state {
debug_assert!(
!self.conn.more_results_exists(),
Expand Down Expand Up @@ -290,7 +312,11 @@ impl<'c, 't, 'tc, T: crate::prelude::Protocol> QueryResult<'c, 't, 'tc, T> {

impl<'c, 't, 'tc, T: crate::prelude::Protocol> Drop for QueryResult<'c, 't, 'tc, T> {
fn drop(&mut self) {
while self.iter().is_some() {}
while self.iter().is_some() {
if log_it() {
println!("{:?} Loggin! I am still loopin", thread::current().id());
}
}
}
}

Expand Down

0 comments on commit 186f615

Please sign in to comment.