Calling pthread_join() with current thread would lead to deadlock. Adding check for it and to return appropriate error code. Signed-off-by: Spoorthi K <spoorthi.k@intel.com>