Black Sun may not be altogether accurate--I personally have no way of knowing. I can tell you whether or not a eighteenth/nineteenth-century British-based romance by a contemporary author is accurate. I can tell you whether a book based on the Titanic is accurate (note: the Cameron movie isn't). But I know absolutely nothing about the Islam Empire in Europe during the medieval time period.
Okay, almost nothing.
The ending of Black Sun always makes me smile. One reason is that the main characters have jobs! Moreover, their jobs are believable to their personalities. It's a nice wrap-up for a series that merits another volume (but at least there's a wrap-up!).
Another reason is Leonard's specific job. The author never explains it. It simply exists. So I will explain it!
Leonard is a medical practitioner (it is unlikely that he would be called a "doctor" though not impossible) who joins boarding officials on their inspections. Members of a port, these officials would meet incoming boats. They would check goods (to prevent smuggling) as well as the sailors' health.
This was not done from any sense of kindness--although Leonard being Leonard, he does behave kindly. It was done to avoid the spread of plague. Plague struck the medieval world numerous times--there were at least two types and either could wipe out a city. Any Mediterranean-based port would have gone out of its way to keep plague-bearing sailors off their shores. Better they die on the ships than die in the streets.
Leonard was not traveling on the ship from anywhere--later text makes clear that he has not yet traveled beyond this particular port. He has come in with the ship and other officials. So presumably the sailors and passengers didn't have plague--even if they weren't entirely healthy.